Robin W on "[Plugin: Private groups] Create a Group via PHP"

ساخت وبلاگ

Now with forums you have multiple entries, so the database can have multiple lines

eg if you forum ID was 2927, and you have set it for group1 and group3, you would have two entries in the postmeta table

meta_id Post_id Meta_key Meta_value
16263 2927 __private_group group1
17652 2927 __private_group group3

Try unpicking the code below to see how the save function works for this

/* Get post metadata for the custom field key 'group'. */ $meta = (array)get_post_meta( $post_id, '_private_group', false ); /* Check if the group was selected. */ if ( !empty ($_POST[$group] )){ /* If selected and already saved, continue looping through the roles and do nothing for this role. */ if ( in_array( $group, $meta ) ) continue; /* If the group was selected and not already saved, add the group as a new value to the 'group' custom field. */ else add_post_meta( $post_id, '_private_group', $group, false ); } /* If role not selected, delete. */ else { delete_post_meta( $post_id, '_private_group', $group ); } } // End loop through site's groups

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 286 تاريخ : سه شنبه 5 مرداد 1395 ساعت: 1:03