Page 1 of 1

S2Member Pro User Registration Form

PostPosted: April 29th, 2011, 3:36 pm
by peterhuk
Hi J/C,

I recently implemented the S2Member Pro registration form.
The form blends in with the theme really well and looks great.

The only problem is I previously created a function for the WP
registration form to dynamically insert Input fields into the form.
The field names and values are generated randomly so I cannot use the
S2 Pro ‘Custom Registration Fields’.

In addition some of the randomly generated keys and values
are temporary values so they would not be suitable
for use in the ‘Custom Registration Fields’ configuration.
Whilst other inputs are hidden and auto completed at point
of page access.

My function also requires some of the key, value pairs to
generates errors in certain conditions halting the registration
process and display an error.

I have not been able to find a similar modification route with
the S2Member registration form.

Any ideas?

Pete..

Re: S2Member Pro User Registration Form

PostPosted: April 29th, 2011, 8:52 pm
by Cristián Lávaque
You could look at the Registration Pro-Form's code and see what you can do with it. wp-content/plugins/s2member-pro/includes/classes/gateways/paypal/paypal-registration-in.inc.php

Re: S2Member Pro User Registration Form

PostPosted: April 29th, 2011, 9:21 pm
by peterhuk
Hi Cristián,

Many thanks for your suggestion. I have already had a look, there
are no filters to return data to S2 so the only option seems to be a
phyical hack to the file.

This would be an easy solution until the next S2 Pro update then
will have to remember where all the changes were.

There is an other approach which is to pull the full complete form
data in form the ws_plugin__s2member_pro_sc_paypal_form and
do the odd regex and str_replace.

Will let you know if I have any success.

Many thanks

Pete..

Re: S2Member Pro User Registration Form

PostPosted: April 29th, 2011, 9:48 pm
by Cristián Lávaque
You could edit the file just to add the hook you want, then do the rest from outside via the hook.

Re: S2Member Pro User Registration Form

PostPosted: April 30th, 2011, 6:19 am
by peterhuk
Hi Cristián,

Many thanks for your suggestion. My biggest concern about altering
program files is that months later an update is implemented and
changes are overwriten then things stop working.

I learned that the hard way and I'm a bit reluctant to make changes
to application files.

I am working on a workaround. If it work I'll let you know.

Pete..

Re: S2Member Pro User Registration Form

PostPosted: April 30th, 2011, 11:18 am
by Cristián Lávaque
I look forward to your update. :)

Re: S2Member Pro User Registration Form

PostPosted: April 30th, 2011, 5:39 pm
by peterhuk
Hi Cristián

O.k, this is where we are at the present. First my shortcode runs to check
If there are any issues.

In either case I run the s2Member-Pro-PayPal-Form register="1" etc shortcode.
The entire form is loaded into a var via the ws_plugin__s2member_pro_sc_paypal_form
filter.

I add my input variables to the end of the form with a cheeky
Code: Select all
$form = str_replace(“</form>”,“my input vars</form>”,$form)

If my shortcode brings up any errors I insert my error code between the
id="s2member-pro-paypal-registration-form-response-div" div
(using strpos to locate the id position and some other cmd’s to find the
position of the end of the tag '>') then use substr_replace
to insert my error code into the response code div section.

All good so far. If my shortcode generates an error I would like to
suppress any S2 Pro errors (else two response div’s looks ugly).

To prevent this I have used
Code: Select all
unset($_POST["s2member_pro_paypal_registration"]);

to suppress the display of S2 Pro user input.

This removes user inputs from the fields but S2 still seems to be
able to produce it’s own errors. Even with cookies disabled S2 Pro
can still generate an error i.e if using an email address that is already
in use (this is fine but I don’t want want it to show whilst my short code
is displaying an error).

This is where I could use your help. What $GLOBALl variable do I need
to unset or alter in order to halt S2 Pro whilst my shortcode has
determined an error?

Ultimately what I would like is if my shortcode determines an error on a
submitted page I would like S2 Pro to treat the page as a non $_POST
(accessed via click) page (if that makes any sense).

Many thanks

Peter..

Re: S2Member Pro User Registration Form

PostPosted: May 1st, 2011, 4:02 am
by peterhuk
Hi Cristián

Just a quick update.

Code: Select all
unset($_POST["s2member_pro_paypal_registration"]);


I found that applying the above earlier in the process, provides the desired
result in this work around.


Pete..

Re: S2Member Pro User Registration Form

PostPosted: May 1st, 2011, 4:05 am
by Cristián Lávaque
Oh. Thanks for the update! :)

I emailed Jason about your question earlier already, so he may come and comment at some point.

Re: S2Member Pro User Registration Form

PostPosted: May 1st, 2011, 12:56 pm
by peterhuk
Hi Cristián,

Do you know what filter loads the

Code: Select all
c_ws_plugin__s2member_pro_paypal_registration::paypal_registration


Class, in paypal-registration.inc.php. This one is buggin me, this appears to be the
class that processes the $_POST data for the registration form.

if I can intrercept this filter before it loads then when my function generates an
error It can suppress the above class otherwise if no errors are generated by my
function then the above can run normally.

Many thanks

Pete..

Re: S2Member Pro User Registration Form

PostPosted: May 1st, 2011, 6:21 pm
by peterhuk
Cristián,

I thnik I've got it, paypal-hooks.inc.php has the following action.

Code: Select all
add_action ("init", "c_ws_plugin__s2member_pro_paypal_registration::paypal_registration");


As this runs at default priority 10 I have added an action which runs at priorty 9. using a similar
wp_verify_nonce check I was able to lock unto this action and simply unset the global post nonce
when a function generates and error.

Once the nonce is cleared the action will not be activated.

Does that sound correct?

Pete..

Re: S2Member Pro User Registration Form

PostPosted: May 3rd, 2011, 9:11 pm
by Jason Caldwell
Hi Pete.
I just finished reading over this thread.

Yes, it sounds like a good solution to me.
unset($_POST["s2member_pro_paypal_checkout"]["nonce"]);

In the mean time, we ARE working to add some Hooks/Filters into the Pro Module.

Re: S2Member Pro User Registration Form

PostPosted: May 4th, 2011, 1:34 am
by peterhuk
Many thanks Jason,

I used
Code: Select all
unset($_POST["s2member_pro_paypal_registration"]["nonce"]);
which seems to work fine.

Pete..