• For those of you who are puzzled over the logging in issue Learnpress presents when a user logs in and enrolls, or when a user purchases a product, there is no need to abandon the plugin entirely! This may be a quick fix but it all lies within this little snippet of code in the form-register.php and form-login.php located within the wp-content/plugins/learnpress/templates/global folder and the wp-content/plugins/learnpress/templates/checkout folder in Learnpress:

    <form name=”learn-press-register” method=”post” action=””>

    Here are the steps to take

    STEP 1:

    in your /global folder

    open: form-register.php

    change <form name=”learn-press-login” method=”post” action=””>
    to: <form name=”learn-press-register” method=”post” action=”/profile”>

    (this will create a redirect back to the users PROFILE page after they complete Learnpress registration. They will be logged in and registered as a student and immediately able to access the dashboard.)

    Make a duplicate copy of form-register.php and name it checkout-form-register.php

    Keep this: <form name=”learn-press-register” method=”post” action=””>

    (when action=”” is left blank, the user is directed back to the previous page they were on after making a purchase.)

    STEP 2

    open form-login.php
    change <form name=”learn-press-login” method=”post” action=””>
    to: <form name=”learn-press-login” method=”post” action=””>

    Make a duplicate copy of form-login.php and name it checkout-form_login.php

    Keep this: <form name=”learn-press-login” method=”post” action=””>

    STEP 3

    Upload the four PHP files back to your GLOBAL folder:

    form-login.php
    checkout-form-login.php
    form-register.php
    checkout-form-register.php

    STEP 4

    in your /checkout folder:

    open: form-register.php

    change: <?php learn_press_get_template( ‘global/form-register.php’ ); ?>
    to: <?php learn_press_get_template( ‘global/checkout-form-register.php’ ); ?>

    STEP 5

    open form-login.php

    change <?php learn_press_get_template(‘global/form-login.php’);?>
    to: <?php learn_press_get_template(‘global/checkout-form-login.php’);?>

    STEP 6

    Upload the two PHP files you just edited back to your CHECKOUT folder:

    form-login.php
    form-register.php

Viewing 15 replies - 1 through 15 (of 19 total)
  • Thread Starter thedvshow

    (@thedvshow)

    YOU NOW CREATED TWO USER SCENARIOS

    1. Any user purchasing a course:

    They click BUY button and go to
    https://www.yourwebsite.com/checkout/ to register or login

    New registrations will be logged in as a student and immediately able to access the dashboard

    Existing users who Log in will be redirected back to the course once a purchase is confirmed

    2. Any user enrolling in a free course:

    New registrations will be logged in and registered as a student then be redirected back to the course page

    Existing users who Log in will be redirected back to the course

    • This reply was modified 4 years, 8 months ago by thedvshow.

    Hi thedvshow,

    Thank you very much for the solution.

    Hie @thedvshow , would you be so kind as to help me out with the login issue? I religiously followed through your tutorial but unfortunately, the user is now redirected back to the Home Page after logging in. All I want is for the user to be redirected to their course of choice after clicking the ‘Buy This Course’ or ‘Take This Course’ button.

    Thank you so much for your help.

    Thread Starter thedvshow

    (@thedvshow)

    Hey @yadley

    What is your domain name so I can take a look at what is going on. Also feel free to send me the .php files as an email attachment [email protected]

    You are a lifesaver! I have just emailed you the PHP files.

    Thanks again

    Thread Starter thedvshow

    (@thedvshow)

    Send me a link to your website too…thanks!

    Thread Starter thedvshow

    (@thedvshow)

    Thanks for the files and the email…all looks well. The first thing I noticed when visiting your site is the login is a popup that seems to bypass Learnpress’ built in registration and login forms you just customized. This is a must for it all to work properly.

    Hi there!

    Thanks so much for this, i’ve been looking for something just like this. I have gone through all your steps and I have the login during the checkout process working ok but I’m just having a little issue with a user logging in from the login page.

    So a new user would complete their purchase and wordpress/learnpress automatically creates a user and enrols them. The user receives an email to reset/create their password to complete their profile.

    After creating their password they are redirected to learnpress login page. When the user logs in they are redirected to the wp-admin/profile (which is the basic wordpress dashboard area) instead of the learnpress profile dashboard.

    If it is an existing user, they go to the login page enter their username and password and are also redirected to the wp-admin/profile instead of learnpress profile.

    Do you know where I’ve gone wrong here??

    I noticed in Step 2 of your instructions your “change from” and “change to” are the same so maybe this is where I’ve made a mistake?

    Thanks so much!

    • This reply was modified 4 years, 7 months ago by carolineelle.

    Actually sorry, please disregard my post previously. I realised that there were some settings within my wordpress account that I needed to change which was blocking the registration forms and was only allowing me to use the guest checkout options.

    All good – your fix is working perfectly – thanks again!

    Thread Starter thedvshow

    (@thedvshow)

    Glad it worked out for you! What is your site about?

    Hello. I did everything as you explained, but it still does not work properly. I might be mistaken, but there are some duplication and same code in your explanation. Please, would you mind help me as I’ve been been fighting this redirection issue for days and no success. When I did everything as you said, my log in/register form just now working, buttons are frozes and do not do anything on click. Any help will be greatly appreciated!

    Thread Starter thedvshow

    (@thedvshow)

    Could be an issue with your server or hosting service. What is your domain url?

    Hie @thedvshow , would you be so kind as to help me out with the login issue? I followed through your tutorial but unfortunately, as soon user enrol for free course and registers is redirected to page that say “This page doesn’t seem to exist. It looks like the link pointing here was faulty. Maybe try searching? ” if i revert back all changes you’ve mentioned everything work like before, user login redirected to profile.

    • This reply was modified 4 years, 6 months ago by alishafqat.
    Thread Starter thedvshow

    (@thedvshow)

    You must also put the redirect link into your Learnpress settings. Does the page exist?

    Hi @thedvshow

    Need some help here. I tried all your steps but there is something not working for me and I can’t seemed to figure it out. Let me explain.

    What I want : New registrations will be logged in and registered as a student then be redirected back to the previous page where he click Enroll.

    What happen now : User is being redirected to the main page.
    I tried changing to <form name=”learn-press-register” method=”post” action=””> but is redirect user to the Dashboard

    Previously before I do any modification following your steps, after any new user registered, he was being redirected to the User Dashboard, which is not what I wanted.

    How do I fix this? Really new some help here. Really appreciate it if you could help me solve this issue

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Redirect after Log in’ is closed to new replies.