Hi Tosin,
Thank you for the question.The plugin does not support automatic featuring. It does have an api for marking user as featured.
You will need some coding assistance. If you are comfortable with code, you can check number of posts of a user when the publish it and mark them as featured.
Regards
BrajeshI made a rough attempt
add_action( 'publish_post', function () { $site_users = get_users( array( 'fields' => 'ID' ) ); $users_post_count = ts_get_user_posts_count($site_users, array( 'post_type' =>'post', 'post_status'=> 'published' )); if ( 24 > $users_post_count ) { return; } bp_featured_members()->add_user( $user_id ); } );
Hi Tosin,
Please give it a try and let me know if it works or not?add_action( 'transition_post_status', function ( $new_status, $old_status, $post ) { if ( 'publish' !== $new_status || ! function_exists( 'bp_featured_members' ) ) { return; } $user = get_user_by( 'id', $post->post_author ); if ( ! $user ) { return; } $users_post_count = count_user_posts( $user->ID, 'post' ); if ( 25 == $users_post_count && ! bp_featured_members()->is_featured( $user->ID ) ) { bp_featured_members()->add_user( $user->ID ); } }, 10, 3 );
Regards
Brajeshit strictly marks on 2. If you want to mark any user who has more than 24 posts(e.g 26, 28 etc), you change the condition from
if ( 25 == $users_post_count && ! bp_featured_members()->is_featured( $user->ID ) ) { bp_featured_members()->add_user( $user->ID ); }
to
if ( $users_post_count >= 25 && ! bp_featured_members()->is_featured( $user->ID ) ) { bp_featured_members()->add_user( $user->ID ); }
Regards
BrajeshHi Tosin,
The problem is we are not storing any flag/marker to differentiate a user who has been marked as featured manually by the site admin.So, if we start automating the non featuring of user, it will impact that.
Is that fine with you?
Regards
BrajeshHi Tosin,
Here is your updated codeadd_action( 'transition_post_status', function ( $new_status, $old_status, $post ) { if ( 'publish' !== $new_status || ! function_exists( 'bp_featured_members' ) ) { return; } $user = get_user_by( 'id', $post->post_author ); if ( ! $user ) { return; } $users_post_count = count_user_posts( $user->ID, 'post' ); $is_featured = bp_featured_members()->is_featured( $user->ID ); if( 25 == $users_post_count && ! $is_featured ){ bp_featured_members()->add_user( $user->ID ); } elseif( $is_featured && $users_post_count< 25 ) { bp_featured_members()->remove_user( $user->ID ); } }, 10, 3 );
Regards
Brajesh
You must be logged in to reply to this topic.