Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #1461991
    #1461996

    Hey Munford,
    You will need to use a function, I have not done this before but I found this code to add to the end of your child theme functions.php file in Appearance ▸ Editor:

    function custom_redirect_after_login( $redirect, $user ) {
        // Check if the user is logging in from the WooCommerce login form
        $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
    
        if ( empty( $requested_redirect_to ) && ( is_account_page() || is_page( 'your-login-page-slug' ) ) ) {
            // URL of your custom My Account page
            $custom_account_page_url = site_url( '/custom-my-account/' );
            $redirect = $custom_account_page_url;
        }
    
        return $redirect;
    }
    add_filter( 'woocommerce_login_redirect', 'custom_redirect_after_login', 10, 2 );
    

    then Replace ‘your-login-page-slug’ with the slug of your WooCommerce login page.
    Replace ‘/custom-my-account/’ with the slug of your new custom My Account page.

    Best regards,
    Mike

    #1462018

    thanks,
    I need to get access to the site files since I’m missing the theme editor.

    #1462021

    Hi,
    That could be due to a plugin like Wordfence Security or a code snippet in your wp-config.php file:

    define( 'DISALLOW_FILE_EDIT', true );
    define( 'DISALLOW_FILE_MODS', true );

    if you see this remove it.
    Otherwise use FTP

    Best regards,
    Mike

    #1462693

    hi MIke
    Is this correct? it did not work for me. It’s still landing on the same page after login.

    function custom_redirect_after_login( $redirect, $user ) {
        // Check if the user is logging in from the WooCommerce login form
        $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
    
        if ( empty( $requested_redirect_to ) && ( is_account_page() || is_page( 'https://www.wift.nu/for-medlemmer/' ) ) ) {
            // URL of your custom My Account page
            $custom_account_page_url = site_url( '/https://www.wift.nu/dashboard/' );
            $redirect = $custom_account_page_url;
        }
    
        return $redirect;
    }
    add_filter( 'woocommerce_login_redirect', 'custom_redirect_after_login', 10, 2 );
    • This reply was modified 4 months, 4 weeks ago by Munford.
    #1462713

    Hi,
    It looks like you are adding the full URL with a leading backslash before it, try using only the page URL like this:

    function custom_redirect_after_login( $redirect, $user ) {
        // Check if the user is logging in from the WooCommerce login form
        $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
    
        if ( empty( $requested_redirect_to ) && ( is_account_page() || is_page( 'for-medlemmer' ) ) ) {
            // URL of your custom My Account page
            $custom_account_page_url = site_url( '/dashboard/' );
            $redirect = $custom_account_page_url;
        }
    
        return $redirect;
    }
    add_filter( 'woocommerce_login_redirect', 'custom_redirect_after_login', 10, 2 );

    Best regards,
    Mike

    #1462715

    Hi
    Thanks
    I tried that but it’s still leading to the “for medlemmer” page, just logged in.

    #1462717

    Hi,
    Above you linked to /bliv-medlem/, not /dashboard/ perhaps that is the issue?

    Best regards,
    Mike

    #1462719

    no I had a redirect rule on there but now it’s disables and it’s still not going to the /dashboard/

    #1462721

    Hi,
    Ok please leave that disabled, and include a admin login so we can adjust the code and a client login so we can test.
    Please note that I don’t think you can test with a admin login, it should be a client level login.

    Best regards,
    Mike

    #1462723

    is there a kriesi email I can use?

    #1462781

    Hi,
    Not one that we have access to, just use any fake one and posted the login details for both accounts in the Private Content area below.

    Best regards,
    Mike

    #1462784
    This reply has been marked as private.
    #1462802

    Hi,
    Thanks, when I try to go to the /for-medlemmer/ page as the client I see a 404 error, I find that the page has not been published.
    For this to work the page needs to be published, it looks like you have two of these pages, so please publish and try again as a client that is not already logined in, such as in incognito mode. If it still doesn’t work I will check and try to find a solution.

    Best regards,
    Mike

    #1462803

    sorry they are both published now.
    When I tried before to login as a client they were published as well, and it didn’t redirect.

    • This reply was modified 4 months, 3 weeks ago by Munford.
    #1462993

    Hi,
    Thank you for your patience, I changed it to this and it seems to work now, please check:

    function custom_redirect_after_login( $redirect, $user ) {
        // URL of your custom My Account page
        $custom_account_page_url = site_url( '/dashboard/' );
    
        // Check if the user is logging in from the specific login page
        if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '/for-medlemmer/' ) !== false ) {
            return $custom_account_page_url;
        }
    
        return $redirect;
    }
    add_filter( 'woocommerce_login_redirect', 'custom_redirect_after_login', 10, 2 );

    Best regards,
    Mike

    #1463000

    yes that works thanks very much!

    #1463006

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 18 posts - 1 through 18 (of 18 total)
  • The topic ‘woocommerce login redirect to another page’ is closed to new replies.