• Hi,

    Look like while using this plugin I can’t later update user role whitout using the back office with

    
    // my_custom_admin - role created by using this plugin
    // my_custom_user - role created by using this plugin
    // $user->roles[0] = 'my_custom_admin'
    
    $user->remove_role('');
    $user->set_role('my_custom_user');

    The user should have now ‘my_custom_user’ role but he still have ‘my_custom_admin’

    Do I miss something

Viewing 1 replies (of 1 total)
  • Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi,

    $user->set_role('my_custom_user'); is correct and enough. set_role() remove all former roles granted to this user itself.

    User Role Editor does not prevent to use any code from WordPress core. Moreover URE uses it itself.

    Check that the $user variable contains the really needed user data, look at the $user->ID.

Viewing 1 replies (of 1 total)
  • The topic ‘Updating user custom role’ is closed to new replies.