• Frank B.

    (@frankbiganski)


    Hi,

    I’m using the LMS LearnPress plugin with the WooCommerce email replies.

    When a student/customer resets their password, they are redirected to the WooCommerce account profile but I want them to be redirected to their LearnPress profile instead.

    I tried customizing the customer-reset-password.php file but I’m not a coder so it didn’t work.

    Original code (partial)
    wc_get_endpoint_url( ‘lost-password’, ”, wc_get_page_permalink( ‘myaccount’ ) ) ) ); ?>

    Custom code (my attempt)
    wc_get_endpoint_url( ‘lost-password’, ”, wc_get_page_permalink( ‘https://thedronecoach.io/lp-profile’ ) ) ) ); ?> (Note, I did not include this “&#8217” – this was placed into this page automatically).

    Is it possible to customise the customer-reset-password.php template to redirect the student to this page https://thedronecoach.io/lp-profile instead of https://thedronecoach.io/account/ after updating their password?

    I’m aware I need to re-upload this custom template after WC updates but I’m fine with that. I have a custom template for customer-new-account.php.

    Cheers,

    Frank

    • This topic was modified 2 weeks, 5 days ago by Frank B..

    The page I need help with: [log in to see the link]

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

    I would advise against changing the plugin’s source code. To redirect users to their LearnPress profile after a password reset, you can hook into the WooCommerce password reset flow and change the redirection URL. WooCommerce has a filter for customizing the redirect after a password reset, which makes this relatively straightforward.

    Here’s how you can implement it:

    1. Add a Custom Function in Your Theme’s functions.php File: This function will hook into the WooCommerce password reset flow and change the redirection URL.

    Here’s a sample code snippet to add to your functions.php file:

    add_filter( 'woocommerce_login_redirect', 'custom_learnpress_password_reset_redirect', 10, 2 );

    function custom_learnpress_password_reset_redirect( $redirect, $user ) {
    // Check if LearnPress is activated
    if ( class_exists( 'LearnPress' ) ) {
    // Replace this with your actual LearnPress profile URL structure
    $learnpress_profile_url = site_url() . '/lp-profile
    return $learnpress_profile_url;
    }

    return $redirect;
    }

    Thanks,

    R

    Thread Starter Frank B.

    (@frankbiganski)

    Thank you Rodrigue! So would the code look like this when adding my LearnPress profile URL structure?

    Thank you!

    add_filter( 'woocommerce_login_redirect', 'custom_learnpress_password_reset_redirect', 10, 2 );

    function custom_learnpress_password_reset_redirect( $redirect, $user ) {
    // Check if LearnPress is activated
    if ( class_exists( 'LearnPress' ) ) {
    // Replace this with your actual LearnPress profile URL structure
    $learnpress_profile_url = site_url() . 'https://thedronecoach.io/lp-profile/
    return $learnpress_profile_url;
    }

    return $redirect;
    }

    Thread Starter Frank B.

    (@frankbiganski)

    This code did not work and caused a critical error.

    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!
    I understand your concern. Please note that we provide support for WooCommerce core features only and do not offer assistance with customizations. If you need more in-depth support or want to consider professional assistance for customization, I can recommend?WooExperts?and?Codeable.io?as options for getting professional help. Alternatively, you can also ask your development questions in the??WooCommerce Community Slack?as custom code falls outside our usual?scope of support.

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.