latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Pro Forms doesn't detect logged in user

Home Forums Community Forum Pro Forms doesn't detect logged in user

This topic contains 24 replies, has 3 voices. Last updated by  Cristián Lávaque 3 years, 5 months ago.

Topic Author Topic
Posted: Tuesday Jul 16th, 2013 at 2:19 pm #53522
RH
Username: s2pm

I used the PayPal Pro Forms to generate a Pro Form (short code below). However, the form always says “Create Profile” and asks for a Username, even when I am logged in. Any reason why it is not detecting the logged in user? The Pro Login Widget and Profile page works fine.

[s2Member-Pro-PayPal-Form level="1" ccaps="" desc="$0.01 USD / Daily (recurring charge, for ongoing access)" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="domainname.tld" ta="0" tp="0" tt="D" ra="1.00" rp="1" rt="D" rr="1" rrt="" rra="2" accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal,visa,mastercard,amex,discover,maestro,solo" coupon="" accept_coupons="1" default_country_code="" captcha="0" /]

List Of Topic Replies

Viewing 24 replies - 1 through 24 (of 24 total)
Author Replies
Author Replies
Posted: Tuesday Jul 16th, 2013 at 2:33 pm #53523
RH
Username: s2pm

So when I am logged in, it asks me to create a profile. But, when I am logged out, it says “Your Profile” and shows my email and username. I have cleared my browser cache and cookies. Now it just says “Create Profile” regardless if I am logged in or logged out.

If I use the form, it works fine, but I have to enter my username even though I am logged in.

Posted: Wednesday Jul 17th, 2013 at 7:29 am #53570

Sounds like a caching thing… Please make sure you don’t have database or object caching enabled, they’re known to cause random issues.

If that’s not it, please try these: Knowledge Base » Common Troubleshooting Tips

Posted: Wednesday Jul 17th, 2013 at 6:17 pm #53588
RH
Username: s2pm

I have query caching enabled at the MySQL server level. I can’t see why that would be the problem since WordPress and s2Member know when I am logged in and logged out, it’s only the Pro Forms having the problem. I don’t have any caching plugins activated. I have disabled all non-essential plugins. I have ran the S2Member Server Scanner with green checks across the board. All plugins and themes are up to date.

Posted: Wednesday Jul 17th, 2013 at 7:05 pm #53589
RM
Username: rmendoza

I am having the same problem. I would like some debugging help. I can’t imagine any plugin or theme that can interfere with this part of the code, besides another member plugin, which I don’t have. Looking forward to a response. Thanks in advance.

Posted: Thursday Jul 18th, 2013 at 7:49 am #53614

I have query caching enabled at the MySQL server level.

Isn’t that database caching? Can you test with that deactivated to see if the problem goes away?

All plugins and themes are up to date.

I can’t imagine any plugin or theme that can interfere with this part of the code

Yeah, sometimes it’s surprising, but there are all kinds of possible plugin conflicts, and the best way to spot them is deactivating and testing to see if the problem goes away. Could you please do these conflict tests please, to eliminate that possibility? Since I don’t remember having seen this issue happen before, it comes down to doing some detective work to try narrowing it down to what’s causing it.

If doing them one by one is too slow for you, you can deactivate them un bulk and test if it’s gone. If you only have s2Member active, then it isn’t a plugin conflict. If the problem is gone when you just have s2Member, then reactivate some plugins and see if it comes back, and so on.

As the troubleshooting tips article says, you could also try reproducing the problem in a clean WP installation with just s2Member added.

Posted: Thursday Jul 18th, 2013 at 9:31 am #53626
RH
Username: s2pm

I have disabled all plugins except s2Member and MU Domain Mapping plugins (as I am running a Network and it would be break if I disabled the domain mapping). I also disabled all MU plugins (s2Hacks). I have switched the theme back to Twenty Twelve. I have cleared MySQL query cache, stopped the server, changed the my.cnf file and set query_cache_size=0. Then started the server again. I cleared my browser cache and cookies. I logged out, logged back in, went to the Pro Forms and still says “Create Profile”.

Posted: Thursday Jul 18th, 2013 at 10:00 am #53633
RH
Username: s2pm

Going into the code where it generates the Pro Form (\s2member-pro\includes\classes\gateways\paypal\paypal-form-in.inc.php:736), I found this line:

$code = preg_replace("/%%username_value%%/", c_ws_plugin__s2member_utils_strings::esc_ds(format_to_edit($_p["s2member_pro_paypal_checkout"]["username"])), $code);

When echoing ($_p[“s2member_pro_paypal_checkout”][“username”]) to the screen, it is blank (even though I am logged in). However, if I replace it with:

$current_user = wp_get_current_user();
$code = preg_replace("/%%username_value%%/", c_ws_plugin__s2member_utils_strings::esc_ds(format_to_edit($current_user->user_login)), $code);

Then, that shows my username.

I can’t find where $_p[“s2member_pro_paypal_checkout”][“username”] is supposed to be populated. Maybe I am missing a step before showing the ProForm? Does that value have to be populated from a previous form post or something?

Posted: Thursday Jul 18th, 2013 at 10:10 am #53634
RH
Username: s2pm

I found where $_p is being set, it was at the top of the Registration code:

$_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST));

When I print_r($_p), it is an empty array.

Should I be posting something to the page that has the ProForm on it?

Posted: Thursday Jul 18th, 2013 at 2:21 pm #53646
RM
Username: rmendoza

I have been reading the code and was unable to see any detection of a user being logged in or not and what to display if there was. Not even a check by global variables. It seems to always show up no matter what. Still looking into this.

Posted: Thursday Jul 18th, 2013 at 2:56 pm #53647
RM
Username: rmendoza

I have been looking into the code and noticed that the create profile shows no matter what. If a user is logged in, is there a way not to show it with the fields filled in? Maybe I am overlooking this, but why would you show their information? Is it for paypal’s purposes?

Posted: Thursday Jul 18th, 2013 at 3:29 pm #53650
RH
Username: s2pm

The code that changes the form depending on if the user is logged in, is below. I’m still trying to trace down why it’s not working:

\s2member-pro\includes\separates\gateways\paypal\paypal.js:601

(handleExistingUsers = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
	{
		if /* If User/Member is already logged in. */ (S2MEMBER_CURRENT_USER_IS_LOGGED_IN)
			{
				$(registrationSection + ' input#s2member-pro-paypal-checkout-first-name').each (function()
					{
						var $this = $(this), val = $this.val ();
						(!val) ? $this.val (S2MEMBER_CURRENT_USER_FIRST_NAME) : null;
					});

				$(registrationSection + ' input#s2member-pro-paypal-checkout-last-name').each (function()
					{
						var $this = $(this), val = $this.val ();
						(!val) ? $this.val (S2MEMBER_CURRENT_USER_LAST_NAME) : null;
					});

				$(registrationSection + ' input#s2member-pro-paypal-checkout-email').val (S2MEMBER_CURRENT_USER_EMAIL).attr (ariaFalseDis);
				$(registrationSection + ' input#s2member-pro-paypal-checkout-username').val (S2MEMBER_CURRENT_USER_LOGIN).attr (ariaFalseDis);

				$(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div').hide ();
				$(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div :input').attr (ariaFalseDis);

				if ($.trim ($(registrationSection + ' > div#s2member-pro-paypal-checkout-form-registration-section-title').html ()) === '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Create Profile", "s2member-front", "s2member")); ?>')
					$(registrationSection + ' > div#s2member-pro-paypal-checkout-form-registration-section-title').html ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Your Profile", "s2member-front", "s2member")); ?>');

				$(customFieldsSection).hide (), $(customFieldsSection + ' :input').attr (ariaFalseDis);
			}
	}) ();
Posted: Thursday Jul 18th, 2013 at 3:49 pm #53652
RH
Username: s2pm

The weirdest thing is, when I log out as Administrator and then log in as a registered member, it shows “Your Profile”, but shows the administrator email and username. So, I delete my cache and cookies, then log in as a registered member again, this time it says “Create Profile” and the username and email are blank.

I am running Firebug and FirePHP to debug what is going on (and yes, I tested it without FirePHP to make sure that wasn’t conflicting either). As soon as I log in, I look at the PHP Variables and notice that “S2MEMBER_CURRENT_USER_LOGIN” is empty and “S2MEMBER_CURRENT_USER_IS_LOGGED_IN” is false. So, these values are not being set after logging in.

Posted: Thursday Jul 18th, 2013 at 4:05 pm #53654
RH
Username: s2pm

I have tested it with three computers on different networks, in IE10, Firefox, Chrome and Safari. Even on my iPhone. They all do the same thing. They don’t recognize the logged in user when using the ProForms.

Posted: Thursday Jul 18th, 2013 at 4:46 pm #53655
RM
Username: rmendoza

I am logged in as an administrator on one browser and it gives the “Create Profile”. On a different browser (different session) I am logged in as a free member and still get the “Create Profile”. And on a third browser, I am logged in as a paid member and still see the “Create Profile.” I will continue to dig deeper

Posted: Thursday Jul 18th, 2013 at 4:53 pm #53656
RH
Username: s2pm

So, I have tracked it down to this file “\s2member\includes\classes\constants.inc.php:156” setting the value “S2MEMBER_CURRENT_USER_IS_LOGGED_IN” to true when I am logged in. And echoing it out to the screen I confirm it is working.

However, when it gets to this file “\s2member\includes\classes\css-js-in.inc.php:105” when echoing “S2MEMBER_CURRENT_USER_IS_LOGGED_IN” out to the screen, it is false.

Posted: Thursday Jul 18th, 2013 at 5:11 pm #53657
RH
Username: s2pm

I have confirmed that in file “\s2member\includes\classes\css-js-themes.inc.php:82” it is correctly detecting I am logged in and the constant “S2MEMBER_CURRENT_USER_IS_LOGGED_IN” outputs true. So, the problem lies with the “\s2member\includes\classes\css-js-in.inc.php” file not loading the constants.

Posted: Thursday Jul 18th, 2013 at 5:20 pm #53659
RM
Username: rmendoza

So, the problem lies with the “\s2member\includes\classes\css-js-in.inc.php” file not loading the constants.

I have no problem with this page. S2MEMBER_CURRENT_USER_IS_LOGGED_IN is true when logged in and false when not. That just sets the global variable for javascript and does work correctly.

Posted: Thursday Jul 18th, 2013 at 5:31 pm #53660
RH
Username: s2pm

I finally figured it out. It was because of the MU Domain Mapping. The script location was the network subsite domain (sub.networkdomain.tld), but the website cookies were only for the mapped domain (www.mappeddomain.tld). Once I changed the location of the script, it loaded the correct values.

Hopefully this helps other people using WordPress MU (Network) with the WordPress MU Domain Mapping plugin.

The way I fixed this was to enabled a plugin that replaced all instances of “sub.networkdomain.tld” with “www.mappeddomain.tld” in the output html.

Posted: Thursday Jul 18th, 2013 at 5:33 pm #53661
RM
Username: rmendoza

I am glad you figured it out. I am not using multi-site. So this does not help me. :( I am still trying to figure this out. I am hoping support can help me.

Posted: Thursday Jul 18th, 2013 at 5:45 pm #53662
RM
Username: rmendoza

I am not sure if I should start a new thread or not. Let me know if I should. Thanks again.

Posted: Thursday Jul 18th, 2013 at 5:46 pm #53663
RH
Username: s2pm

You might want to since I think support stopped responding to me on this thread. I’ve noticed they only respond once or twice per thread.

Posted: Thursday Jul 18th, 2013 at 7:06 pm #53667
RH
Username: s2pm

Here is the code I placed in s2hacks.php MU plugin file:

add_filter('script_loader_src', 's2hack_src_loader_filter');
add_filter('style_loader_src', 's2hack_src_loader_filter');

function s2hack_src_loader_filter($src)
{
  $src = str_ireplace("sub2.sub.networkdomain.com", "sub2.networkdomain.com", $src);
  return $src;
}

This is probably not typical for most WordPress Network installations, but in my unique case I had to install WordPress Network on a subdomain. This causes all my subsites to have two subdomains (sub2.sub, sub3.sub, etc.). This causes problems with a lot of Urls.

Posted: Saturday Jul 20th, 2013 at 6:42 am #53708

RH Said:
Hopefully this helps other people using WordPress MU (Network) with the WordPress MU Domain Mapping plugin.

Thanks for sharing your findings and solution, RH. I’m sure it’ll help someone else with a setup similar to yours. :)

RM Said:
I am not using multi-site. So this does not help me. :( I am still trying to figure this out. I am hoping support can help me.

In your replies above I didn’t see you confirming having done all the troubleshooting steps described in the article I linked to. Could you confirmed you did them all? Knowledge Base » Common Troubleshooting Tips

Also, what exactly is the problem you’re having? You mentioned it’s the same problem, but I’m not sure if it’s exactly the same. Is it that your pro-form is showing the registration fields when you’re logged in? If I’m confused, could you please explain in detail and maybe show me screenshots?

By the way, since RH’s problem was due to login sessions, could you make sure your installation doesn’t have this problem? See: Knowledge Base » Logged In, But Am I?

Posted: Saturday Jul 20th, 2013 at 6:44 am #53709

I just noticed you created a new thread here: http://www.s2member.com/forums/topic/pro-forms-does-not-detect-logged-in-user/

We can continue there if you want.

Viewing 24 replies - 1 through 24 (of 24 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.