Automatically assign user role based on email not working

Hello,

I found this thread (https://projectdmc.org/support/topic/automatically-assign-user-role-based-on-email-domain/) and I thought I got it to work yesterday but it is not working. Can someone help me with this?

It keeps defaulting to Portal Member.

add_action( 'um_user_register', 'update_users_company_info', 10, 2 );
function update_users_company_info( $user_id, $args ){
  if( isset( $args['user_email'] ) ){
    list($user, $domain) = explode('@', $args['user_email'] );

    if ($domain == 'amyling.com') {
      wp_update_user( array( 'ID' => $user_id, 'role' => 'um_prospect' ) );
      // update_field('user_company', 1725, $user_id);
    }
  }
}

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer