Add additional user roles at Registration
-
Hi
I have Youzify installed and it’s working great!
I am trying to add some additional user roles when someone registers at my site. I have written the code and it works just fine when using the normal WordPress registration process. However, when I use the same code but the Youzify registration page, the new roles are not added to the new user.
Here is my code:
function my_additional_roles( $user_id ) {
$new_user = get_user_by( 'ID', $user_id );
////Add additional user roles
if ( in_array( 'subscriber', (array)$new_user->roles ) ) {
$new_user->add_role( 'wpas_user' ); //Support User
$new_user->add_role( 'academy_student' ); //Academy LMS Student
}
}
add_action( 'user_register', 'my_additional_roles' );I suspect that Youzify may be using a different function to ‘user_register’ that I am trying to add my action to but I cannot seem to find in your code any references.
Could someone please point me in the right direction.
Thanks so much!
- The topic ‘Add additional user roles at Registration’ is closed to new replies.