• Resolved kalebweeter14

    (@kalebweeter14)


    I have tried plugins and css codes but I cannot get a redirect to work after a user has logged in. It takes them to the default place everytime.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    WHich login form are you using?
    Please share the page URL to check the issue.

    Thread Starter kalebweeter14

    (@kalebweeter14)

    Thread Starter kalebweeter14

    (@kalebweeter14)

    I am using Woocommerce Login

    Thread Starter kalebweeter14

    (@kalebweeter14)

    I wanted it to redirect to Straightforwardpiano.com/my-account/your-courses

    Thread Starter kalebweeter14

    (@kalebweeter14)

    Here is the code I’ve used and inserted into the plugin code snippets

    function woo_login_redirect( $url, $request, $user ){
    if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
    if( $user->has_cap( 'administrator') or $user->has_cap( 'author')) {
    $url = admin_url();
    } else {
    $url = home_url('my-account/your-courses'); // HERE GOES THE REDIRECTION URL
    }
    }
    return $url;
    }
    add_filter('login_redirect', 'woo_login_redirect', 10, 3 );

    Hello,

    Please try the below code.

    add_filter( 'woocommerce_login_redirect', 'njengah_login_redirect_to_cart' ); 
     
    function njengah_login_redirect_to_cart( $redirect ) {
    	
        $redirectPageID = url_to_postid($redirect );
        $checkoutPageID = wc_get_page_id('checkout');
        
    	//Check if the user is logging in from the checkout 
    	
        if( $redirectPageID == $checkoutPageID ){
            return $redirect;
        }
    	
    	//redirect the customer to the cart page 
     
        return wc_get_page_permalink( 'cart' );
    }

    PS- replace the cart with your page permalink.

    • This reply was modified 3 years, 11 months ago by Abhishek.
    Thread Starter kalebweeter14

    (@kalebweeter14)

    Edit: Nevermind I was pasting the code from the email notification.

    • This reply was modified 3 years, 11 months ago by kalebweeter14.
    • This reply was modified 3 years, 11 months ago by kalebweeter14.
    • This reply was modified 3 years, 11 months ago by kalebweeter14.
    Thread Starter kalebweeter14

    (@kalebweeter14)

    This code is not working to no matter what I do. It either sends the user to the cart or checkout page or breaks the website. I gave you the permalink. I am a complete beginner to seeing code. Give me a solution that I can simply copy paste.

    Thread Starter kalebweeter14

    (@kalebweeter14)

    I solved it on my own. I changed the Login menu item url to the place I wanted it to go. It worked out because in order to get to the page I wanted them to go an automatic login popup had to show up.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Not Able to do Login Redirect’ is closed to new replies.