I imported 4000 users on 1st October 2015 as "subscribers" and now need to change all their roles to a custom role called "To Be Approved". So what I need is to change the roles of these subscribers to my custom role of "To Be Approved" only if they registered on 1st October. I'm using this plugin to filter the date they registered in the dashboard - https://wordpress.org/plugins/recently-registered/ and this plugin https://wordpress.org/plugins/user-role-editor/ for my custom role called "To Be Approved". It is taking time to manually change their roles in the dashboard. I have used the code below to start me off but am a newbie with PHP. Any help would be appreciated:
// Access to get_users
$blogusers = get_users( 'subscriber' );
foreach ($blogusers as $user) {
$date = '2015-10-01';
$registered = ($user_info->user_registered);
if($date == $registered) {
$u = new WP_User( $user->ID );
// Remove role
$u->remove_role( 'subscriber' );
// Add role
$u->add_role( 'to_be_approved' );
}
}
Am I on the right track with this?
Thanks