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
$hook = "ws_plugin__s2member_during_custom_registration_fields_after_last_name";
add_action($hook, "my_custom_fields");
function my_custom_fields($vars = FALSE)
{
echo '<select name="ws_plugin__s2member_custom_reg_field_state">';
echo '<option value="GA">Georgia</option>';
echo '<option value="FL">Flordia</option>';
echo '</select>';
}
$hook = "ws_plugin__s2member_before_configure_user_registration";
add_action($hook, "add_my_custom_fields");
function add_my_custom_fields($vars = FALSE)
{
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"] .= ",State";
}
?>
Jason Caldwell wrote:Gotchya. Yea, this is a feature that we're working on as well. Custom Registration Fields are being revamped to support many new features in a future version of s2Member. The hold-up is the UI portion. As you can imagine, the UI for this has to be very inutitive; so we're taking our time on that part.
Until then, you could use Hooks/Filters for s2Member.
Inside /s2member/includes/functions/register-access.inc.php
you will find this function: ws_plugin__s2member_custom_registration_fields()
which integrates several Hooks that you can use to add things of your own ( i.e. custom code ).
Here is an example, which adds a drop down SELECT menu.
( put something like this inside the functions.php for your WP theme )
- Code: Select all
<?php
$hook = "ws_plugin__s2member_during_custom_registration_fields_after_last_name";
add_action($hook, "my_custom_fields");
function my_custom_fields($vars = FALSE)
{
echo '<select name="ws_plugin__s2member_custom_reg_field_state">';
echo '<option value="GA">Georgia</option>';
echo '<option value="FL">Flordia</option>';
echo '</select>';
}
$hook = "ws_plugin__s2member_before_configure_user_registration";
add_action($hook, "add_my_custom_fields");
function add_my_custom_fields($vars = FALSE)
{
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"] .= ",State";
}
?>
Or, if you really need to; you can just make some direct edits inside this file:
/s2member/includes/functions/register-access.inc.php
martonic wrote:Hi again,
It seems that if I want to have drop-downs on the registration page, I have to keep everything related to those fields in lower-case letters. I also hacked register-access.inc.php so it would not request duplicate information. Then, it works okay.
However, I can't find a hook that will deliver all of the registration information, including custom registration field values as entered by the end user (whether I'm using drop-downs, or not). Is there a hook that I can use for this?
Thanks, Marty
S2MEMBER_CURRENT_USER_FIELDS
This will always be a JSON encoded array, in (string) format. An empty JSON encoded array, in (string) format, if not logged in. This JSON encoded array will contain the following fields: id, ip, email, login, first_name, last_name, display_name, subscr_id, custom. If you've configured additional Custom Fields, those Custom Fields will also be added to this array. For example, if you configured the Custom Field: Street Address, it would be included in this array as: street_address. Custom Field references are converted to lowercase format, and spaces are replaced by underscores. You can do print_r(json_decode(S2MEMBER_CURRENT_USER_FIELDS, true)); to get a full list for testing.
<?php $fields = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true); ?>
<?php echo $fields["first_name"]; ?> <?php echo $fields["last_name"]; ?>
This would output the first and last name for the current user.
Custom Fields are also included in the JSON decoded array.
<?php print_r(json_decode(S2MEMBER_CURRENT_USER_FIELDS, true)); ?>
( Displays a full list of all associative array elements. )
<?php
$user = wp_get_current_user();
$fields = get_usermeta($user->ID, "s2member_custom_fields");
print_r($fields);
?>
// get custom registration fields set by s2member
$telephone = "";
$address = "";
$gender = "M";
$year = 1900;
$key = "s2member_custom_fields";
$fields = get_user_meta($wp_id, $key, false);
@$gender = $fields[0]["gender"];
@$year = $fields[0]["birthyear"];
@$address = $fields[0]["mailing_address"];
@$telephone = $fields[0]["telephone"];
Users browsing this forum: Google [Bot], Yahoo [Bot] and 11 guests