Skip to content

Instantly share code, notes, and snippets.

@sadrul
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadrul/3806d6f90d9a16791c56 to your computer and use it in GitHub Desktop.
Save sadrul/3806d6f90d9a16791c56 to your computer and use it in GitHub Desktop.
BBpress forum role change in bulk
<?php
add_action( 'wp', array($this, 'change_existing_user_forum_role') );
function change_existing_user_forum_role(){
$args = array (
'role' => 'bbp_spectator',
);
$user_query = new WP_User_Query( $args );
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
bbp_set_user_role($user->ID, 'bbp_participant');
$user = new WP_User($user->ID);
$user->remove_role('bbp_spectator');
$user->add_role('bbp_participant');
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment