Page 1 of 1

Registration mail with original URL

PostPosted: November 28th, 2011, 6:02 am
by shaimo
Hi,

When a user tries to access a restricted page and then fills in the registration form, it would be really great to also include in the e-mail with the password the URL of the original page he/she was trying to access so they can easily get back to the requested content. Is that possible? How?

Thanks!

Re: Registration mail with original URL

PostPosted: November 29th, 2011, 1:53 am
by Cristián Lávaque
When the user gets redirected from the protected content to the Membership Options page, some vars are available, which include the page he was redirected from. WP Admin -> s2Member -> API / Scripting -> Membership Options Page Variables

You could have a PHP script in your Membership Options page that stores that page in a cookie and then, after the person creates his account and logs in, have another PHP script in your login welcome page that checks if the cookie with the pre-registration page exists, and if so redirect him there.

If you don't know how to code all this, you could post a job in a freelance website like jobs.wordpress.net, oDesk.com or eLance.com.

I hope it helps. :)

Re: Registration mail with original URL

PostPosted: November 30th, 2011, 9:24 am
by shaimo
Cristian,

Thanks a lot for the reply!!
Do you know which hook I need to use? Is it ws_plugin__s2member_after_wp_redirect_w_mop_vars? I did try to register a hook for both this one and ws_plugin__s2member_before_membership_options_page, but I'm not sure I'm getting called back and I also don't know how to extract the seeking_uri variable from there...
Any help would be greatly appreciated!!

Thanks!

Re: Registration mail with original URL

PostPosted: November 30th, 2011, 4:46 pm
by shaimo
Hi Cristian,

I made some progress today - was able to put the right hook in place to "catch" the original url and write it into the cookie.
I'm now trying to write a hook/filter that will redirect the login to the saved url if it exists. Unfortunately I was unable to achieve this so far. I actually suspect there is some bug in the s2member code. Looking in login-redirect.inc.php I think the condition in line 69 achieves the opposite logic intended. Can it be?
In any case I thought the ws_plugin__s2member_login_redirect filter is what I need to use, but there is absolutely no documentation of how to make it work. Do you know what my function need to return and where it should put the requested redirect-to url?

Many thanks!