Tips and Tricks HQ Support Portal › Forums › WP Affiliate Platform › WP Affiliate Troubleshooting › Automatically Log into Affiliate Account not working for WP Role Subscriber
- This topic has 7 replies, 2 voices, and was last updated 12 years ago by dirkkirchner.
-
AuthorPosts
-
November 13, 2012 at 12:47 pm #7897dirkkirchnerMember
I purchased Affiliate Platform a few days ago and use version 5.3.6. with s2member.
Everything works fine and you´ve created a really great plugin. Thank you very much.
My issue is the automatically login function. The automatic login works for the WP Roles Administrator, Editor, Author and Contributor but not for Subscribers.
The wp_affiliate_debug.log shows for the working Roles:
[11/13/2012 7:55 AM] - SUCCESS :WP User Integration - attempting to log this user into the affiliate account. Username: User123
[11/13/2012 7:55 AM] - SUCCESS :Found a corresponding affiliate account for this WP User! Logging the user into affiliate account.Only for WP Roles Subsribers there is no entry.
My guess is that the function handle_wp_user_login in wp_aff_includes2.php is not called for Subscriber logins.
Best Regards
Dirk
PS: Even the site is not working you can have a look here: [http://www.online-mlm-insider.de/produkte/]
November 14, 2012 at 2:57 am #51349adminKeymasterThe 2nd debug line from what you have posted above actually gets shown after the user is logged into the system so the plugin definitely logged user ID “User123” as an affiliate.
I did a test just now with a subscriber role user on my test server to make sure nothing weird is going on.
Those two debug lines are not getting printed for when you log in with a subscriber user role? If they are not then that means the WordPress after login hooks are not getting fired on your site for subscriber role (another membership plugin can do this). How are you logging into WordPress? Using the standard WordPress login?
November 14, 2012 at 9:16 am #51350dirkkirchnerMemberThe two lines are not getting printed when I log in with a subscriber user role.
I’m using the standard WordPress log in but I think it is contlolled by s2member.
November 15, 2012 at 7:04 am #51351adminKeymasterokay. you definitely have a plugin that is preventing WordPress from firing that after login hook for subscriber role user (the affiliate plugin use this to detect the login). The affiliate plugin can’t auto login a user if it doesn’t receive the notification from WordPress.
Please do this test to find out which plugin is doing this:
https://support.tipsandtricks-hq.com/forums/topic/test-to-identy-a-conflicting-theme-or-plugin
November 16, 2012 at 8:40 am #51352dirkkirchnerMemberThank you. It is definitely the s2member-plugin. I’ll have a look if they have a hook in or after their login routines and if I can use that.
November 16, 2012 at 2:46 pm #51353dirkkirchnerMemberOk. I found a solution.
s2member has a hook called ws_plugin__s2member_before_login_redirect.
I use this to run a similar function as your handle_wp_user_login and it works very well.
If you want I can post the complete code here.
Thank you very much.
November 17, 2012 at 3:30 am #51354adminKeymasterYeah sure please paste the code here.
November 17, 2012 at 9:33 am #51355dirkkirchnerMemberHere is what I did.
Code:
Code:add_action(“ws_plugin__s2member_before_login_redirect”, “login_to_wp_affiliate_platform”);
function login_to_wp_affiliate_platform($vars = array())
{
$username = $vars [username];
wp_affiliate_log_debug(“WP User Integration – attempting to log this user into the affiliate account. Username: “.$username,true);
if(wp_aff_check_if_account_exists_by_affiliate_id($username)){
$_SESSION[‘user_id’]= $username;
setcookie(“user_id”, $username, time()+60*60*6, “/”,COOKIE_DOMAIN); //set cookie for 6 hours
wp_affiliate_log_debug(“Found a corresponding affiliate account for this WP User! Logging the user into affiliate account.”,true);
}else{
wp_affiliate_log_debug(“No corresponding affiliate ID exists for this WP User (“.$username.”) so can’t log this user in!”,true);
}
}This code goes into a file named s2-hacks.php in the folder wp-content/mu-plugins (this ist a WordPress folder for ‘must use’ plugins. If you dont have such a folder, just create one).
After the log in routine is completed by the s2member plugin there ist a hook called ws_plugin__s2member_before_login_redirect. I added an action / function called login_to_wp_affiliate_platform to this hook.
Works fine and I hope this is helpful for other users.
-
AuthorPosts
- You must be logged in to reply to this topic.