This seems to be a good starting point.
Ok, so whilst there doesn’t seem to be a function I can filter that based on the post count, I could potentially run a function that changes someone’s role based on their post count every time they login? That would keep database queries to a minimum and still ensure the update happens fairly regularly.
Any idea what filter or action I can use when a user logs in? Can I just use the wp_login action?
Potentially something like this, although it isn’t working as far as I can tell:
function bbp_change_user_role_login($user) {
$user_id = get_current_user_id($user);
$current_user_role = bbp_get_user_role($user_id);
$new_role_forum_role="bbp_moderator";
$user_post_count = bbp_get_user_post_count( $user_id );
if (($current_user_role = "bbp_participant") and ($user_post_count > 20)) {
bbp_set_user_role( $user_id, $new_forum_role );
}
}
add_action('wp_login', 'bbp_change_user_role_login');
I’d suggest you crack open this plugin which does topic and reply counts
bbp topic count
you can also check out this plugin which does user ranking
bbp user ranking
Thanks. Do you know how I can loop through all users in a function? I can’t seem to work it out.
$users= get_users () ;
if ( $users ) :
foreach ( $users as $user ) :
$user_data = get_userdata( $user->ID );
//whatever you want here
endforeach ;
endif ;