0

I tried to look for everything on Google but I had little luck.

I created a login and registration form on the same page before making a purchase if you are not logged in.

To log in, use the following code:

$creds = array(
          'user_login'    => $user_data->data->user_login,
          'user_password' => $pwd_login,
          'remember'      => true
        );

wp_signon( $creds, false );

wp_redirect( home_url() . '/log-checkout/?prodotto=' . $_GET['prodotto'] );
exit();

Everything works properly and the login is done.

The problem occurs when I go to the next payment page and go back.

When I go back from the payment form to the login / registration form I should no longer see the login / registration form but rather to see which account the user I created is logged in and this works perfectly too.

To view it the user must reload the page again.

How can I make that when the user comes back to see which email is logged in he doesn't have to reload the page to see it?

Is there a simple WordPress function that configures authentication cookies?

Thanks a lot to those who will help me.

PS. For the payment page I use Stripe Checkout.

  • Did you try with wp_set_auth_cookie after wp_signon(); ? LIKE $user = wp_signon( $creds, false ); wp_set_current_user($user->ID); wp_set_auth_cookie($user->ID, true, false ); – Chetan Vaghela Sep 24 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.