• Resolved adriangzz98

    (@adriangzz98)


    Hello, is it possible to change the Redirect on success link depending on the user role? I want to redirect customers to one url and vendors to another. I think is not possible with the built in features but if you could provide me with some code or suggestion I will appreciate it.

    I have the pro version

Viewing 1 replies (of 1 total)
  • Hi @adriangzz98

    At the moment, this functionality is not available in our plugin but we are providing alg_wc_ev_user_account_activated hook which can allow you to change your redirect link on success.

    You can add the below codes in your theme’s functions.php file. You can change your user role name in $vendor_role_name variable and you can change your redirect URLs in $redirect_url variable.

    /**
     * Custom redirection on user activation success
     */
    function my_custom_redirection_on_user_activation_success( $user_id ) {
        $user_obj   = get_user_by( 'id', $user_id );
        $user_roles = ( isset($user_obj->roles) && ! empty($user_obj->roles) ) ? $user_obj->roles : false;
        if ( false === $user_roles ) {
            return;
        }
        $redirect_url     = get_permalink( get_option('woocommerce_myaccount_page_id') ); // Default redirect URL for customer and other users
        $vendor_role_name = 'vendor'; // You can add your vendor role name
        if ( in_array( $vendor_role_name, $user_roles, true ) ) {
            $redirect_url = get_bloginfo('url'); // Redirect URL for vendor user
        }
        wp_safe_redirect( $redirect_url );
        exit;
    }
    add_action( 'alg_wc_ev_user_account_activated', 'my_custom_redirection_on_user_activation_success', 99 );
Viewing 1 replies (of 1 total)
  • The topic ‘Redirect after registration by role’ is closed to new replies.