Posts and Groups have different post status names and we need to set up a status sync logic. This logic can be manipulated via filters.
If the post status is set to draft, pending or trash the group status is set to hidden. If the post status is set to publish the group status will be set to public. Post status private will set the group status to private.
It could be the case that you want to change this logic. For example, if you want to set the group to private but the post should stay published.
You can manipulate this logic for Groups and Post separately.
Change Group Status Sync Logic: If you want to manipulate the group status sync if the post status get changed use this hook: bf_attached_group_status
See the example function:
add_filter('bf_attached_group_status', 'my_bf_attached_group_status', 10 , 3);
/**
* @param $group_status
* @param $old_group_status
* @param $post_status
* @return mixed
*/
function my_bf_attached_group_status($group_status, $old_group_status, $post_status){
// Check if the group status was set to private and if yes, keep the group private also if the post is published
if( $post_status == 'publish' && $old_group_status == 'private')
$group_status = $old_group_status;
return $group_status;
}
Change Posts Status Sync Logic: If you want to manipulate the post status if the group status gets change, use this hook: bf_attached_grouppost_post_status
See the example function:
add_filter('bf_attached_grouppost_post_status', 'my_bf_attached_grouppost_post_status', 10 , 2);
/**
* @param $post_status
* @param $group_status
* @return string
*/
function my_bf_attached_grouppost_post_status($post_status, $group_status ){
// Check if the group status is set to private and if yes, set the post status to published</strong><br />
if( $group_status == 'private' )
$post_status = 'publish';
return $post_status;
}
By default, the post and group status is synced.
Posts and Groups have different post status names and we need to set up a status sync logic. This logic can be manipulated via filters.
If the post status is set to draft, pending or trash the group status is set to hidden.
If the post status is set to publish the group status will be set to public.
Post status private will set the group status to private.
It could be the case that you want to change this logic. For example, if you want to set the group to private but the post should stay published.
You can manipulate this logic for Groups and Post separately.
Change Group Status Sync Logic: If you want to manipulate the group status sync if the post status get changed use this hook:
bf_attached_group_status
See the example function:
Change Posts Status Sync Logic: If you want to manipulate the post status if the group status gets change, use this hook:
bf_attached_grouppost_post_status
See the example function: