Hi @albertoaranda
You can try this code snippet:
add_action("um_registration_complete","um_042121_change_user_role", 1, 2 );
function um_042121_change_user_role( $user_id, $args ){
if( isset( $args['user_email'] ) ){
list($user, $domain) = explode('@', $args['user_email'] );
if ($domain == 'gmail.com') {
wp_update_user( array( 'ID' => $user_id, 'role' => 'premium-member' ) );
}
}
}
The above code will change the role to ‘premium-member’ when the email provider is Gmail.
Regards,
Hey there!
..This thread has been inactive for a while so we’re going to go ahead and mark it Resolved. Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂
Regards,
Note about the code:
You must use the RoleID see an example in this link:
https://ww.wp.xz.cn/support/topic/automatically-assign-user-role-based-on-email-domain/
-
This reply was modified 5 years, 1 month ago by
missveronica.