Community Support Forums — WordPress® ( Users Helping Users ) — 2011-10-26T12:36:44-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=2822 2011-10-26T12:36:44-05:00 http://www.primothemes.com/forums/viewtopic.php?t=2822&p=48868#p48868 <![CDATA[Re: Custom registration field help]]> Statistics: Posted by nemoprincess — October 26th, 2011, 12:36 pm


]]>
2011-10-26T12:27:50-05:00 http://www.primothemes.com/forums/viewtopic.php?t=2822&p=48867#p48867 <![CDATA[Re: Custom registration field help]]> 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.

Statistics: Posted by Jason Caldwell — October 26th, 2011, 12:27 pm


]]>
2011-10-26T11:59:29-05:00 http://www.primothemes.com/forums/viewtopic.php?t=2822&p=48863#p48863 <![CDATA[Re: Custom registration field help]]> I' m using the latest versions of both Wordpress and the pro versione of S2Member.
Could you help me please? Thanks a lot

Statistics: Posted by nemoprincess — October 26th, 2011, 11:59 am


]]>
2011-03-30T07:44:30-05:00 http://www.primothemes.com/forums/viewtopic.php?t=2822&p=8609#p8609 <![CDATA[Re: Custom registration field help]]> Statistics: Posted by kiawah1 — March 30th, 2011, 7:44 am


]]>
2011-03-26T17:14:56-05:00 http://www.primothemes.com/forums/viewtopic.php?t=2822&p=8403#p8403 <![CDATA[Re: Custom registration field help]]> 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:
<?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

Statistics: Posted by Jason Caldwell — March 26th, 2011, 5:14 pm


]]>
2011-03-25T20:01:48-05:00 http://www.primothemes.com/forums/viewtopic.php?t=2822&p=8363#p8363 <![CDATA[Re: Custom registration field help]]> Statistics: Posted by Cristián Lávaque — March 25th, 2011, 8:01 pm


]]>
2011-03-25T13:48:38-05:00 http://www.primothemes.com/forums/viewtopic.php?t=2822&p=8353#p8353 <![CDATA[Custom registration field help]]> Statistics: Posted by kiawah1 — March 25th, 2011, 1:48 pm


]]>