LeoLopesWeb
11/10/2019 - 7:06 PM

After registration redirect - redirect

// After registration redirect
function check_user_role($roles, $user_id = NULL) {
  if ($user_id) $user = get_userdata($user_id);
        else $user = wp_get_current_user();
     if (empty($user)) return false;   
    foreach ($user->roles as $role) {     
  if (in_array($role, $roles)) {
      return true;
    }
   }
    return false;
}
// Create a Redirection Function + WP Action
   function custom_registration_redirect() {
      if (check_user_role(array('customer'))) { // Add the User Role in the Array
        return home_url('/l'); //Add your redirect page slug here
    }
}
add_action('woocommerce_registration_redirect', 'custom_registration_redirect', 2);