Membership auto-login

Seems to me that after a user registers using the membership plugin and selects a subscription, they should be automatically logged in like so:

<?php
add_action( 'membership_subscription_form_after_subscriptions', 'membership_autologin' );

function membership_autologin($user_id) {
  if($user_id && function_exists('wp_set_auth_cookie')) {
    wp_set_auth_cookie($user_id);
  }
}

?>
  • dennisonwolfe
    • Design Lord, Child of Thor

    Hi guys -

    Does Staff or Barry have any feedback on this forum topic, or this one, with respect to Membership 3.1+?:
    https://premium.wpmudev.org/forums/topic/registration-process-1

    I'm hoping to avoid pushing new members through a couple additional steps of logging in after (1) creating a WP account and (2) paying for a membership.

    The user experience would be much better if (for instance Paypal) were to direct new members back and have them already logged in.

    Thanks for any thoughts on this, particularly confirmation that code on this topic or the other one works on Membership 3.1+. I kind of dread wading into customizing php unless I absolutely have to and know it will work.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.