Simple Membership Plugin › Forums › Simple Membership Plugin › How to manually "login" the user outside the plugin?
Tagged: access, login, membership, signin
- This topic has 5 replies, 4 voices, and was last updated 9 years, 2 months ago by
bobgarrett.
-
AuthorPosts
-
February 10, 2017 at 4:55 pm #10123
Nosebleed
ParticipantHello!
Since the plugin has its own “authenticaton” and “login” state, is there a way to programatically login a specific user? Let’s say in my code under a particular circumstance or action, I want to login the user not only to WP ( with signon ), but I’d like also to “login” the user to the membership account. Is there a way to do that?
Regards!
February 11, 2017 at 3:41 am #10126mbrsolution
ModeratorHi, what happens when the user logs in as a member? Are they able to see the WP admin menu?
February 11, 2017 at 7:35 am #10129Nosebleed
ParticipantHello!
The users logs in as a subscriber. I have disabled the admin bar for them and they are just doing whatever they doing on the front end with some more custom features. I will try and explain what I need.
When the users logs in via the login form provided by the plugin everything is fine, because it uses the default WordPress signon and also sets another cookie that is created by the plugin and also logs them in the plugin. I want to use my login form which uses the default WordPress login, but the form doesn’t know that there is another cookie to be set via the plugin and it doesn’t login the user.
So the question is how can I manually ( programatically ) trigger the plugin authentication using the already logged in user’s credentials?
https://core.trac.wordpress.org/browser/tags/4.6.1/src/wp-includes/user.php#L28
This function is triggered when the user is loggedin by default. I can attach whatever I want here – https://core.trac.wordpress.org/browser/tags/4.6.1/src/wp-includes/user.php#L104 on the wp_login action – which is to authenticate the user via the plugin’s cookie.
I hope I was being helpful.
Regards.
February 11, 2017 at 10:04 pm #10132mbrsolution
ModeratorThank you for providing the extra information, this will help the plugin developers investigate further your issue.
Regards
February 14, 2017 at 6:24 am #10145admin
KeymasterYou can call the login() function of the SwpmAuth class to manually execute a member login event.
Below is an example snippet of code that shows you how to use it. You can use it in your custom code.
$auth = SwpmAuth::get_instance(); $auth->login($username, $password);//TODO - pass the actual username and password of the memberFebruary 20, 2017 at 4:57 pm #10217bobgarrett
ParticipantI have a similar problem in that members log in via a separate plugins login feature.
Mostly this works without a problem but it seems some users successfully log in to core WordPress features but don’t get access to the Membership features.
I cannot understand why this only affects a few.
Have you any suggestions? -
AuthorPosts
- You must be logged in to reply to this topic.