Last active
August 29, 2015 14:26
-
-
Save sadrul/3806d6f90d9a16791c56 to your computer and use it in GitHub Desktop.
BBpress forum role change in bulk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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