Im interested to know if it possible Assign a secondary role IF the user it register by a specific role.
For example:
If the user register as "OWNER" wordpress must assign the existing user role "TEACHER".
I found different funtions online but nobody works, so i was wondering this specific needed its not implemented by wordpress.
Thank you!
EDIT:
I try to manage by myself a code but still i have some issue to compare the current user role at the moment of the registration:
add_action( 'user_register', 'add_secondary_role', 10, 1 );
function add_secondary_role( $user_id ) {
$user = get_user_by('id', $user_id);
if ( in_array( $roles, 'owner' ) ) {
$user->add_role('teacher');
} else if ( in_array( $roles, 'guest' ) ) {
$user->add_role('student');
}
}