#4781
Vladimir
Keymaster

1st, $user_role and $user variables are not defined in these code lines:


if ( $user_role == ‘customer’ ) {
   $user->remove_role( ‘new-web’ );

You should start from getting current user:


$user = wp_get_current_user();
if(!$user) {
return;
}

Then check if current user is not administrator.
Then make manipulations with user role.
If you use $user->add_role(), $user->remove_role(), there is no need to use wp_update_user().