I’m trying to figure out how to loop through an array of user id’s and call the wp_update_user function to update roles in wordpress.
The problem is that is stops looping after 10 changes even though there are 85 items in the array.
I thought maybe this could be a security feature? Is there a way around this? Any ideas will be awesome as I am well and truly stuck.
if(!function_exists('get_user_to_edit')){
include(ABSPATH.'/wp-admin/includes/user.php');
foreach ($user_id as $user_ids){
//echo $user_ids;
$role = "Master Trainer";
$user_info = wp_update_user( array('ID'=>$user_ids ,'role' => $role ) );
if ( is_wp_error( $user_info ) ) {
} else {
echo $user_ids.'n';
}
}
}