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™
<?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. */
}
}
?>
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.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
Users browsing this forum: Yahoo [Bot] and 2 guests