Home Forums WoodMart support forum Registration Redirect Don't Work

Registration Redirect Don't Work

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #202198

    emyeele
    Participant

    Hello, I am having the same issue this user had here: https://xtemos.com/forums/topic/registration-redirect-dont-work/

    I’ve been dealing with this issue for hours and still cannot get any redirect functions to work. Is there possibly something in the template that is preventing custom redirects to now work? I have tried implementing custom functions and different plugins, however no sort of redirection will work. I have disabled every plugin, changed themes, ect. I am at a lost here.

    #202329

    Hello,

    Please make the full backup of your site and check how it works on the default theme to detect if our theme causes the problem. Register / Login is the functionality of the Woocommerce and our theme does not have the option to change it. Please check how it works on our demo. In order to change this, you will have to find a plugin or customize.

    Best Regards

    #202449

    emyeele
    Participant

    I actually figured it out within minutes of posting for help, however thank you as always. In case any one needs this in the future, here is the code:

    // Check whether or not the current user specified roles

    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;
    }

    function custom_registration_redirect() {

    if (check_user_role(array(‘customer’))) { //change “customer” to your respective roles

    return site_url(‘/’); //change “/” and append to your site’s homepage URL if need to redirect to a different page within your site
    }

    }

    add_action(‘woocommerce_registration_redirect’, ‘custom_registration_redirect’, 2);

    #202522

    Hello,

    Thank you for sharing the code. If you have any questions please feel free to contact us.

    Best Regards

Viewing 4 posts - 1 through 4 (of 4 total)