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.

Auto-login after register + some other bits

Home Forums Community Forum Auto-login after register + some other bits

This topic contains 19 replies, has 2 voices. Last updated by  Cristián Lávaque 4 years, 4 months ago.

Topic Author Topic
Posted: Monday Aug 6th, 2012 at 8:20 am #21216

Hi,
Thanks for this great bit of code…. does just what I need…

I am using the Pro version & I have a couple of small issues:

1) I have added the auto-login after register code as follows:

<?php
add_action('ws_plugin__s2member_during_configure_user_registration', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
        if (!is_admin() && $vars['processed'] === 'yes') {
                wp_new_user_notification($vars['user_id'], $vars['pass']);
                wp_set_auth_cookie($vars['user_id'], false, is_ssl());
                c_ws_plugin__s2member_login_redirects::login_redirect($vars['login']);
        }
}
?>

and this works – but I had a thank-you page set up for levels above 0 (since they are paid subscribers via paypal pro forms) and this is now ignored – all subscribers go to the same page (once-only download, subscriber-only content) after registering.

I would like the paid subscribers (level 1 & 2) to go to the thank-you page (which has a link to once-only download content) after they purchase/register. Is this possible?

2) Is it possible to disable the registration email alltogether? There is no need for the user to return to the site after initial registration as subscription content will be emailed…

3) Small bug – If i try to register an existing email address, I get returned to the registration form, but there is some html leakage out of the email address field on the form – perhaps you forgot to escape the content?

4) I have installed s2member server-wide on a multi-site worpress installation with domain mapping. This does lead to a lot of wrong URLs appearing (after registration, login etc.) – they show the parent domain not the one mapped to this blog. Would s2member handle this better if I installed it on only the blog that I am using it with (I don’t have a multi-site licence)? Or are these problems caused by WordPress?

Many Thanks,
Andy

List Of Topic Replies

Viewing 19 replies - 1 through 19 (of 19 total)
Author Replies
Author Replies
Posted: Tuesday Aug 7th, 2012 at 6:43 am #21346

and this works – but I had a thank-you page set up for levels above 0 (since they are paid subscribers via paypal pro forms) and this is now ignored – all subscribers go to the same page (once-only download, subscriber-only content) after registering.

I would like the paid subscribers (level 1 & 2) to go to the thank-you page (which has a link to once-only download content) after they purchase/register. Is this possible?

Well, you’re bypassing the success URL when you log the person in and send him to the Login Welcome page.

Now, you could use the login Welcome Page to show the message you want, even customizing it based on the user’s level using conditionals. [hilite path]Dashboard -› s2Member® -› API / Scripting -› Simple/Shortcode Conditionals[/hilite]

And if you want to show the message on just the first login, you can use this: [hilite path]Dashboard -› s2Member® -› General Options -› One-Time Offers (Upon Login)[/hilite]

2) Is it possible to disable the registration email alltogether? There is no need for the user to return to the site after initial registration as subscription content will be emailed…

No, s2Member lets you customize the New User email, but I don’t see a setting to not send it. If the person is registering an account, I think it’s good to send him his login info and a welcome. You can change the message to what works best for your site. [hilite path]Dashboard -› s2Member® -› General Options -› Email Configuration -> New User[/hilite]

3) Small bug – If i try to register an existing email address, I get returned to the registration form, but there is some html leakage out of the email address field on the form – perhaps you forgot to escape the content?

I couldn’t reproduce this. I just get a warning “That Email Address is already in use. Please try again” and the form prepopulated with what I submitted.

Did you customize the pro-form in some way?

It could also be another plugin or the theme affecting yours? As a test, try with the default TwentyEleven theme. Or deactivate other plugins one by one, checking after each if the problem continues.

4) I have installed s2member server-wide on a multi-site worpress installation with domain mapping. This does lead to a lot of wrong URLs appearing (after registration, login etc.) – they show the parent domain not the one mapped to this blog. Would s2member handle this better if I installed it on only the blog that I am using it with (I don’t have a multi-site licence)? Or are these problems caused by WordPress?

That reminds me of this: http://www.s2member.com/forums/topic/login-widget-on-multisite/#post-19982

Maybe you have a variation of that happening? [hilite mono]network_site_url[/hilite] instead of [hilite mono]site_url[/hilite] being used.


I hope that helps. :)

Posted: Thursday Aug 9th, 2012 at 5:58 am #21610

Many Thanks for that – it makes more sense now… :-)

1) The ONE-TIME OFFERS options looks like it will do the trick – I have set up a 1st time page for paid subscribers (level 1 & 2) as a thank-you page and set this to first-time only view….
Haven’t been able to test it yet though as I am now encountering a new problem (see below)…

3) You are right – your code is not to blame – this is a problem with the mailhide feature of wp-recaptcha plugin, which is attempting to hide the completed email field content (and breaking it in the process). Unfortunately there seems to be no way of switching it off (that works) within the form – their [nohide] tag doesn’t have an effect when placed around the whole s2member form shortcode… Unfortunately I need emails in posts and pages to be hidden…

4) I have to move the site now to the final domain, so I am sure I will have a lot of fun with this!

New problem is I am getting a’Error #1. User authentication failed.’ message when attempting to do a paypal payment – this is new and I don’t think I have changed anything (to a sandbox paypal pro account) – any ideas?

Posted: Thursday Aug 9th, 2012 at 7:10 am #21612

PS – I have solved the problem for now at least…. switched off payflow API stuff – dunno if that was the problem or something else, but I am able to make payments on sandbox again….

Posted: Thursday Aug 9th, 2012 at 9:44 am #21631

Update:
Switching off payflow api just ended up giving me a different set of errors so have switched to live paypal account for testing which works, but, now I am able to make credit card purchases….

6) What is the procedure to setup invoice generation for customers paying by credit card?
At the moment they just get taken back to my Thank-you page and sent an email saying they are now registered on the site…
Also if I am a new user and I make a purchase the correct landing page is selected (using the one-time only code above). However, if I am already registered (for free) and decide to purchase a membership, i get returned to the payment page but with the text ‘Thank you. Your account has been updated – Please log back in now.’ in the response space… I need make sure that these ‘upgraded’ members get treated the same way as new membership purchasers – ie receive an invoice…

Any help?
Thanks,
Andy

Posted: Friday Aug 10th, 2012 at 5:50 am #21687

3)

You could try deactivating that plugin in just the page where the pro-form is. http://wordpress.org/extend/plugins/plugin-organizer/

6)

When the user registers, he gets the New User email. [hilite path]Dashboard -› s2Member® -› General Options -› Email Configuration -> New User[/hilite]

When the user pays to register, he gests a Signup Confirmation email. [hilite path]Dashboard -› s2Member® -› PayPal® Options -› Signup Confirmation email[/hilite]

When the user is already registered and pays to upgrade, the email sent is another one and there isn’t an interface to edit it yet, but you can use a hack. http://www.primothemes.com/forums/viewtopic.php?f=4&t=10368&p=33365#p33365

I hope that helps!

Posted: Friday Aug 10th, 2012 at 6:53 am #21695

Thanks a lot – I’ll see how I get on.
I haven’t come across a detailed s2member/paypal pro integration guide – is there such a thing?
I can’t help thinking it would save you a lot of time if there was!

cheers, Andy

Posted: Friday Aug 10th, 2012 at 7:23 am #21699

Well, it’s all there in [hilite path]Dashboard -› s2Member® -› PayPal® Options[/hilite]. Just go panel by panel filling out the fields, or following the instructions on what to do over at PayPal.

Here’s a video: Video » s2Member (PayPal® Options/Buttons)

And this other one: http://www.youtube.com/watch?v=A0jOq2MRTVQ

I hope that helps :)

Posted: Tuesday Aug 14th, 2012 at 8:13 am #21965

Hi,
The video is only about paypal standard (and the other one is just for payflow) – a step-by-step account of s2member configuration for paypal pro would be invaluable….

I guess where I am struggling is in terms of figgering out what I need to do to handle post-transaction. At the moment, credit card payments are successfully being processed, and the new subscriber is being logged in and sent to the page I have setup in ‘one-time offers’, but the new subscriber gets only an email titled ‘congratulations your membership has been approved’ and another with username and password. There is no receipt of payment (the most important bit for many!).

Do I need IPN on for this? or is that just for my own back-end stuff?

I have set up a ‘sign-up confirmation email (pro form)’, but this doesn’t appear to be sent…

Any thoughts?
Many thanks

Posted: Tuesday Aug 14th, 2012 at 9:48 am #21990

… am also wondering what I can do if subscriber makes direct payment (credit card) and wants to give a different shipping address (on this scenario, level 4 subscribers also receive printed subscription by post)….

This is an additional requirement from client – maybe s2member was not the right choice …… :-(

Thanks for your help… it is appreciated!

Posted: Tuesday Aug 14th, 2012 at 10:41 am #22002

whoops – I spoke too soon…
I see you have thought about physical shipping. the new ‘ns’ ‘no shipping’ directive doesn’t work in pro forms though, so I have added custom fields (optional) to the level 4 form. That works – Phew!

I set the shipping fields up so they all contain ‘same as card’ by default, so the customer wouldn’t have to fill in twice.
However the first thing the customer sees is the shipping address fields which they fill in, then hit payment button and the rest of the card address fields come up and they then have to fill it in again…

It would be much better for the client if the behaviour was less kludgy and more like a standard shopping cart – ie the card address then the shipping address (and in an ideal world – the shipping address autopopulated…)

Any way to do this? Bearing in mind that it is only for one level….

PS still haven’t got anywhere on the post-transaction emails, so any help would be great…

Cheers,
Andy

Posted: Wednesday Aug 15th, 2012 at 8:20 am #22075

About the emails, my reply would be as above: http://www.s2member.com/forums/topic/auto-login-after-register-some-other-bits/#post-21687

Now, if transactions are working, the emails would be sent, even if you didn’t customize them, there’s the default text for each. If they aren’t being sent, then it’s most probable that the transaction has something wrong. Please make sure you have logging enabled and do a test checkout to get new log entries. [hilite path]Dashboard -› s2Member® -› PayPal® Options -› Account Details -› Logging[/hilite]

This may help too: Knowledge Base » Troubleshooting Email Delivery Problems

Yes, the instructions in the videos are for PayPal in the first one, and the new PayFlow settings for PayPal Pro in the second one. That’s what you need for PayPal Pro, besides having the service enabled in your PayPal account, of course.

About the order of the fields in the pro-form, you can try moving them around a bit in the template. Pre Sale FAQs » Is it possible to modify s2Member® Pro Form templates?

I hope that helps. :)

Posted: Wednesday Aug 15th, 2012 at 9:44 am #22096

Thanks for your help – sorry to go on and on – but this project is going on and on!

1) the only emails being sent out (even though the transaction is successful and recorded as such in the log) are the New User Registration (to admin) and Username/passwords (to customer). The ‘Signup confirmation Email (Pro Form)’ is not being sent…

2) It seems that though I have setup a custom ‘success’ URL in my pro forms, it is not working:

success="/subscription-confirmation/?email=%%user_email%%&fname=%%user_first_name%%&lname=%%user_last_name%%&subscr_id=%%subscr_id%%&sub_level=%%level%%&desc=%%desc%%&sub_value=%%ra%%"

… the credit card purchaser goes to /subscription-confirmation/ when they have completed the transaction, but without the URL paramaters…

3) When I do get it working (oh happy day!), what happens to the content of the custom (delivery address) fields I added to the level 4 form? Can I get these as shortcodes? can I get them emailed to me? are they stored somewhere in the database?

FYI:
A) I have disabled auto-login for the paying subscribers (level 1 up), whilst retaining it for free subscribers (level 0). I did this because I thought it might be messing up the post-transaction process. I used the code below in s2hacks.php:

<?php
add_action('ws_plugin__s2member_during_configure_user_registration', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
        if (!is_admin() && $vars['processed'] === 'yes') {
                wp_new_user_notification($vars['user_id'], $vars['pass']);
                wp_set_auth_cookie($vars['user_id'], false, is_ssl());
		if ($vars['_pmr']['ws_plugin__s2member_custom_reg_field_s2member_level']==0) {
                c_ws_plugin__s2member_login_redirects::login_redirect($vars['login']);
                }
        }
}
?>

B) I don’t have Payflow account details filled in on this installation – I understood from reading the notes that it only applied to recurring billing and I am not using recurring billing. I have however filled in the Paypal API section…

I do appreciate any help you can give me on this, as I am waaaay beyond deadline now on this and struggling…

Thanks,
Andy

Posted: Wednesday Aug 15th, 2012 at 10:16 am #22098

and…
4) When I use paypal to pay (something I haven’t tried for a while – I have been doing credit card transactions), it just returns me to the originating pro form page with a text box at the top which says
“Thank you. Your account has been approved.
— You’ll receive an email momentarily.”

However, the Sign-up confirmation email is being sent out in this case….

Don’t get it at all any more….
Ideas?
Many Thanks

Posted: Wednesday Aug 15th, 2012 at 10:57 am #22101

Custom ‘success’ url shortcode attributes and s2hacks.php mutually exclusive?

Update after further testing:
In the last test described above, I had tried removing the s2hacks.php file (with the login redirect code) altogether – this ensured that the confirmation emails went out from both paypal and credit card orders, although only some of the shortcodes worked (%%level%% & %%desc%% & %%ra%% all returned null values)… But of course the paypal return wasn’t going to this page ata all as described above.

I amended and reinstated the s2hacks.php file as follows (to bypass auto-login for the paid subscribers altogether):

<?php
add_action('ws_plugin__s2member_during_configure_user_registration', 's2_auto_login_after_registration');
function s2_auto_login_after_registration($vars = array()) {
        if (!is_admin() && $vars['processed'] === 'yes') {
           if ($vars['_pmr']['ws_plugin__s2member_custom_reg_field_s2member_level']==0) {
                wp_new_user_notification($vars['user_id'], $vars['pass']);
                wp_set_auth_cookie($vars['user_id'], false, is_ssl());
                c_ws_plugin__s2member_login_redirects::login_redirect($vars['login']);
                }
        }
}
?>

Now both credit card and paypal purchases come back to the purchase confirmation page, and the confirmation emails go out.

Now however, it looks like the s2hacks.php is ignoring ALL the parameters (the shortcode attributes) from the custom success URL string.

Any way of ensuring that the values get passed on by s2hacks.php? (and any idea what happened to the missing ones?)

Posted: Wednesday Aug 15th, 2012 at 11:58 am #22114

correction – after further testing… got a bit confusing matching emails to payments there as emails were being delayed…

In fact it is simply the case that if there is that s2hacks.php file there, there is no confirmation email and the shortcode attribute parameters are lost in the custom success string.

I dont think the hack is working properly anyway ecause I am using the ws_plugin__s2member_custom_reg_field_s2member_level variable, and this appears only to be set if they are already logged in? Dunno how I would find out what level they have just paid for when they are not yet logged in, which is the current situation…

I have removed the s2hacks.php and given up on auto-login for new level 0 subscribers.

The other questions – how to get the remaining shortcode attributes to be passed to my success page, and how to get hold of the custom fields still remain. I suspect that the answer to the second question is something to do with ‘cv pipes’

Posted: Thursday Aug 16th, 2012 at 8:33 am #22221

Thanks for the updates, Andrew. I wasn’t aware of the incompatibility between the auto-login hack and the [hilite mono]success[/hilite] attribute’s replacement codes. About how to tell if it’s a free user, you could [hilite code]print_r($vars)[/hilite] in the hack and see what else you could use do identify him. You could probably add a piped value to the [hilite mono]custom[/hilite] attribute for the free registrations to pick them up in the hack’s conditional.

The other questions – how to get the remaining shortcode attributes to be passed to my success page, and how to get hold of the custom fields still remain. I suspect that the answer to the second question is something to do with ‘cv pipes’

So, even after removing the s2hacks.php file, your [hilite mono]success[/hilite] attribute’s replacement codes are not working? Or some are and others not? Which exactly?

Posted: Thursday Aug 16th, 2012 at 9:30 am #22233

OK – I thought that shortcode attributes like ra and desc would be available as %% variables to pass to the ‘success’ url, but they aren’t. I have now used CV1 etc to pass these values through to the success page.

But the second question still remains :
1) how do I get at the custom pro-form fields so I can send them as CV fields as well? I investigated the ‘get_s2member_custom_fields’ function, but it appears I need to know the user_id for this – how do I get this when the user is not yet logged in????????

2)I would like to then put them in the registration email – clues?

3) is there a list somewhere of the %%vars%% available?
NB: I am having to find out all this by trial and error – a lot of it is pretty basic stuff IMO, but only seems to be rndomly documented in support requests – Better documentation please please!! Save yourself and every user a lot of headache…. doesn’t matter how great the code is if the documentation is not there…

Thanks
Andy

Posted: Thursday Aug 16th, 2012 at 10:49 am #22243

apologies – I found the list of %% replacement codes – under ‘signup confirmation email (pro form)’…. general comment stands though :-)

Although that list does not appear to be complete – I was using %%user_first_name%% & %%user_email%% & %%user_last_name%% & %%user_email%% – none of these occur in the list (I got them from somewhere…) Are there more that you’re not telling?

Wish List:
0) How about a function/capability for placing custom fields automatically into %% replacement codes?…

More importantly…
1) Comprehensive documentation (on a website/PDF – so it is searchable)
2) integrated Billing address functionality – if sites want to start selling physical goods to members (or like me the spec is changed half-way through), they don’t want to throw away s2member and start again with a different payment integration…
3) Auto-login after registration capability (check-box)…
4) Better invoicing functionality built-in

Posted: Friday Aug 17th, 2012 at 6:18 am #22307

Thanks for the feedback, Andrew.

[hilite mono]%%first_name%%[/hilite], [hilite mono]%%last_name%%[/hilite], [hilite mono]%%full_name%%[/hilite] and [hilite mono]%%payer_email%%[/hilite] are available for the Signup Confirmation email. [hilite path]Dashboard -› s2Member® -› PayPal® Options -› Signup Confirmation Email[/hilite]

The custom profile fields are available as replacement codes in the New User email, but not in the Signup Confirmation emails. [hilite path]Dashboard -› s2Member® -› General Options -› Email Configuration -> New User[/hilite]

The replacement codes you see there are the ones available, there aren’t non-documented ones as far as I know. If you really need new ones, you’d have to hack the code for it to add them, I guess.

About using the custom values for the custom profile fields, you could probably use JavaScript to do it in the form, so that what is entered into a profile field, gets added as a custom value.

Thanks a lot for the great requests/suggestions, I’m forwarding them to Jason to consider. :)

Viewing 19 replies - 1 through 19 (of 19 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.