- This topic has 1 reply, 2 voices, and was last updated 8 years, 4 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
WordPress Membership Plugin
Simple Membership Plugin › Forums › Simple Membership Plugin › Auto log-in a member created by another plug-in
Tagged: login woocommerce registration
Hi!
I am trying to auto log-in the member that is created by Woocommerce when the visitor purchases a membership. I’m using the SWPM WooCommerce Addon for that, and everything is working fine. I auto log in users successfully to WP, with the following function:
function auto_login_new_user($order_id) {
$order = new WC_Order( $order_id );
$user_id = $order->get_customer_id();
$user = get_user_by( 'id', $user_id );
wp_set_current_user( $user_id, $user->user_login );
wp_set_auth_cookie( $user_id );
do_action( 'wp_login', $user->user_login );
}
add_action('woocommerce_checkout_order_processed', 'auto_login_new_user');
This logs the user into WP but not SWPM. I tried adding this inside the function:
do_action('swpm_login', $user->user_login, $user->user_pass, true);
but the problem is that $user->user_pass returns the hashed password, and swpm_login requires the unhashed password.
Is there any way to do this? I can’t figure out how to:
– Either return an unhashed password into swpm_login
– Or login into SWPM in a way that doesn’t require passwords, similar to how wp_set_current_user and wp_set_auth_cookie only need the user ID.
Thank you very much and regards,
Gabriel
Hashed passwords cannot be hashed.
Yes, there probably is a way to accomplish what you are trying to do, but please realize this request is outside the scope of the free technical support. I am required to refer you to our paid support service, for further assistance in this matter:
https://simple-membership-plugin.com/paid-support-simple-membership-plugin/