PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Custom registration field help

s2Member Plugin. A Membership plugin for WordPress®.

Custom registration field help

Postby kiawah1 » March 25th, 2011, 1:48 pm

In the custom registration field area, I am trying to add a drop down so when they register they will see the current S1 and S2 User names in the drop down. These are for referral fee purposes but I cannot figure out how to have the system pull the user names. Can anyone tell me the best way to do this? Thanks!
User avatar
kiawah1
Registered User
Registered User
 
Posts: 8
Joined: March 16, 2011

Re: Custom registration field help

Postby Cristián Lávaque » March 25th, 2011, 8:01 pm

I'm sorry, it probably is very obvious but I'm not understanding the question well. What are the S1 and S2 usernames?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Custom registration field help

Postby Jason Caldwell » March 26th, 2011, 5:14 pm

Custom Registration Fields ( a developer how-to )

How to set option values dynamically,
and how to set a default selected option value too.


Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
Code: Select all
<?php
/*
Setting options dynamically for Custom Registration Fields.
*/
add_action ("ws_plugin__s2member_before_custom_field_gen", "my_dynamic_field_options");
function my_dynamic_field_options ($vars = array ())
    {
        $_field = &$vars["__refs"]["_field"]; /* By "reference". */
        /* See: http://www.php.net/manual/en/language.references.spot.php. */
        /**/
        if ($_field["id"] === "country_code")
            {
                $_field["options"] = "US|United States|default" . "\n";
                $_field["options"] .= "CA|Canada" . "\n";
                $_field["options"] .= "VI|Virgin Islands (U.S.)";
            }
    }
/*
Setting a default value for Custom Registration Fields.
*/
add_action ("ws_plugin__s2member_before_custom_field_gen", "my_dynamic_field_values");
function my_dynamic_field_values ($vars = array ())
    {
        $references = &$vars["__refs"]; /* Array of variable "references". */
        $_field = &$vars["__refs"]["_field"]; /* By "reference". */
        /* See: http://www.php.net/manual/en/language.references.spot.php. */
        /**/
        if ($_field["id"] === "country_code")
            {
                if (empty ($references["_submission"]) && empty ($references["_value"]))
                    /* If a form was not just submitted. And, there is no default value. */
                    
                    $references
["_value"] = "CA"; /* Set the default value. */
            }
    }
?>

Video
I'm also attaching a video tutorial on this topic,
where I explain how this code works in great detail.

MP4 Video file: http://www.s2member.com/wp-content/uplo ... ically.mp4
Attachments
s2-hacks.zip
(633 Bytes) Downloaded 24 times
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Custom registration field help

Postby kiawah1 » March 30th, 2011, 7:44 am

Thank you for the tutorial. This should be a big help.
User avatar
kiawah1
Registered User
Registered User
 
Posts: 8
Joined: March 16, 2011

Re: Custom registration field help

Postby nemoprincess » October 26th, 2011, 11:59 am

Hi Jason, I have the same need, to add automatically some values of a select for my custom registration field. I have tried your code, but I get a blank page when I try to go to mywebsite/wp-admin
I' m using the latest versions of both Wordpress and the pro versione of S2Member.
Could you help me please? Thanks a lot
User avatar
nemoprincess
Registered User
Registered User
 
Posts: 24
Joined: October 5, 2011
Location: London, UK

Re: Custom registration field help

Postby Jason Caldwell » October 26th, 2011, 12:27 pm

Thanks for the follow-up.
nemoprincess wrote:Hi Jason, I have the same need, to add automatically some values of a select for my custom registration field. I have tried your code, but I get a blank page when I try to go to mywebsite/wp-admin
I' m using the latest versions of both Wordpress and the pro versione of S2Member.
Could you help me please? Thanks a lot
It sounds like you *might* have leading or trailing white-space characters in your hacks file. This may have happened when you copied from the forum. I'm attaching a zip file with the proper syntax. Please let us know if you continue to have trouble in this regard.
Attachments
s2-hacks.zip
(633 Bytes) Downloaded 24 times
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Custom registration field help

Postby nemoprincess » October 26th, 2011, 12:36 pm

Ops...sorry, you' re right, Thanks
User avatar
nemoprincess
Registered User
Registered User
 
Posts: 24
Joined: October 5, 2011
Location: London, UK


Return to s2Member Plugin

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

cron