Add second user role at registration

Home Forums Legacy Support Support queries How-to & Troubleshooting Add second user role at registration

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #218429
    gsjaak_118
    Participant
    Hi I have made a custom registration form where people can sign up as instructors. I am trying to add a second user role when they signup, but i cant get it to work. I am using multisite. So what i want is that when someone registers as an instructor they also get the user role "vendor". This is the code i tried (but nothing happens .. :/)   if (is_multisite()) { add_action( 'wpmu_activate_user', 'add_secondary_role', 10, 1 ); } else { add_action( 'user_register', 'add_secondary_role', 10, 1 ); }   function add_secondary_role( $user_ID ) { $user = get_user_by('id', $user_ID); $user->add_role('vendor');   }
    #218581
    Diana
    Participant
    @gsjaak_118 Instead of this, Register a new user role as "vendor" on your site and then set it as a default role for newly registered user(Assign permissions and roles which you want to give to that user role). I guess, this will do the trick. SO you need not to add a user role programatically at the time when users registering on your site
    #218675
    gsjaak_118
    Participant
    Hi Diana, I was thinking about this indeed. I am trying to find a list of all the capabilities that are assigned to the instructor user role (i am pretty sure i saw a document about this the other day but i cant find it anymore..). Could you provide me this list of capabilities? Kind regards
    #218724
    Diana
    Participant
    @gsjaak_118 I guess this plugin works for you: https://wordpress.org/plugins/user-role-editor/
    #220373
    gsjaak_118
    Participant
    thanks, i dont need a plugin i just want to know all the capabilites that wplms assigns by default to an instructor. could you provide me this list?
    #220510
    logan
    Member
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Add second user role at registration’ is closed to new replies.