Statistics: Posted by Cristián Lávaque — July 9th, 2011, 9:05 pm
<?php
add_action('ws_plugin__s2member_during_configure_user_registration_front_side', 'member_directory_include');
add_action('ws_plugin__s2member_during_configure_user_registration_admin_side', 'member_directory_include');
add_action('ws_plugin__s2member_after_handle_profile_modifications', 'member_directory_include');
add_action('ws_plugin__s2member_during_users_list_update_cols', 'member_directory_include');
function member_directory_include($vars = array ()) {
$s2_custom_fields = get_user_field('s2member_custom_fields', $vars['user_id']);
if ($s2_custom_fields['member_directory_include'] === '1')
update_user_meta($vars['user_id'], '_tern_wp_member_list', 'Enter List Name');
else
delete_user_meta($vars['user_id'], '_tern_wp_member_list');
}
?>
Statistics: Posted by nashvillegeek — July 9th, 2011, 8:14 am
<?php
add_action('ws_plugin__s2member_during_configure_user_registration_front_side', 'member_directory_include');
add_action('ws_plugin__s2member_during_configure_user_registration_admin_side', 'member_directory_include');
add_action('ws_plugin__s2member_after_handle_profile_modifications', 'member_directory_include');
add_action('ws_plugin__s2member_during_users_list_update_cols', 'member_directory_include');
function member_directory_include($vars = array ()) {
$s2_custom_fields = get_user_field('s2member_custom_fields', $vars['user_id']);
if ($s2_custom_fields['member_directory_include'] === '1')
update_user_option($vars['user_id'], '_tern_wp_member_list', 'My List');
else
delete_user_option($vars['user_id'], '_tern_wp_member_list');
}
?>
Statistics: Posted by Cristián Lávaque — July 9th, 2011, 2:55 am
/**
* Delete user option with global blog capability.
*
* User options are just like user metadata except that they have support for
* global blog options. If the 'global' parameter is false, which it is by default
* it will prepend the WordPress table prefix to the option name.
*
* @since 3.0.0
* @uses $wpdb WordPress database object for queries
*
* @param int $user_id User ID
* @param string $option_name User option name.
* @param bool $global Optional. Whether option name is global or blog specific. Default false (blog specific).
* @return unknown
*/
function delete_user_option( $user_id, $option_name, $global = false )
Statistics: Posted by Jason Caldwell — July 9th, 2011, 2:49 am
<?php
add_action('ws_plugin__s2member_during_configure_user_registration_front_side', 'member_directory_include');
add_action('ws_plugin__s2member_during_configure_user_registration_admin_side', 'member_directory_include');
add_action('ws_plugin__s2member_after_handle_profile_modifications', 'member_directory_include');
add_action('ws_plugin__s2member_during_users_list_update_cols', 'member_directory_include');
function member_directory_include($vars = array ()) {
$fields = get_user_field('s2member_custom_fields', $vars['user_id']);
update_user_option($vars['user_id'], '_tern_wp_member_list', ($fields['member_directory_include'] === '1' ? 'My List' : false));
}
?>
nashvillegeek wrote:
Thanks to you both for helping with this. I feel like I've been taken to school. I will try this out tomorrow.
This thread in particular has answered so many looming questions for me. Great information and examples! I imagine others will take alot from this, as well.
Thank you! I'll get back with the results.
Statistics: Posted by Cristián Lávaque — July 9th, 2011, 2:41 am
Statistics: Posted by nashvillegeek — July 9th, 2011, 1:49 am
Statistics: Posted by Jason Caldwell — July 9th, 2011, 12:08 am
<?php
add_action('ws_plugin__s2member_during_configure_user_registration_front_side', 'member_directory_include');
add_action('ws_plugin__s2member_during_configure_user_registration_admin_side', 'member_directory_include');
add_action('ws_plugin__s2member_after_handle_profile_modifications', 'member_directory_include');
add_action('ws_plugin__s2member_during_users_list_update_cols', 'member_directory_include');
function member_directory_include($vars = array ()) {
$s2_custom_fields = get_user_field('s2member_custom_fields', $vars['user_id']);
if ($s2_custom_fields['member_directory_include'] === '1')
add_user_meta($vars['user_id'], '_tern_wp_member_list', 'My List');
else
delete_user_meta($vars['user_id'], '_tern_wp_member_list');
}
?>
Statistics: Posted by Cristián Lávaque — July 8th, 2011, 11:54 pm
add_action('ws_plugin__s2member_during_users_list_update_cols', 'member_directory_include');
Statistics: Posted by Jason Caldwell — July 8th, 2011, 11:38 pm
<?php
add_action('ws_plugin__s2member_during_configure_user_registration_front_side', 'member_directory_include');
add_action('ws_plugin__s2member_during_configure_user_registration_admin_side', 'member_directory_include');
add_action('ws_plugin__s2member_after_handle_profile_modifications', 'member_directory_include');
function member_directory_include($vars = array ()) {
$s2_custom_fields = get_user_field('s2member_custom_fields', $vars['user_id']);
if ($s2_custom_fields['member_directory_include'] === '1')
add_user_meta($vars['user_id'], '_tern_wp_member_list', 'My List');
else
delete_user_meta($vars['user_id'], '_tern_wp_member_list');
}
?>
Statistics: Posted by Cristián Lávaque — July 8th, 2011, 11:30 pm
Statistics: Posted by Cristián Lávaque — July 8th, 2011, 11:24 pm
Statistics: Posted by Jason Caldwell — July 8th, 2011, 11:13 pm
Statistics: Posted by Cristián Lávaque — July 8th, 2011, 11:11 pm
<?php
add_action ("ws_plugin__s2member_during_configure_user_registration_front_side", "my_handler");
add_action ("ws_plugin__s2member_during_configure_user_registration_admin_side", "my_handler");
function my_handler ($vars = array ())
{
$user_id = $vars["user_id"];
// Do something here.
}
?>
Statistics: Posted by Jason Caldwell — July 8th, 2011, 11:07 pm
Statistics: Posted by Cristián Lávaque — July 8th, 2011, 10:39 pm
Sorry, can you please confirm when you're trying to update this data? During/after Registration, or during/after a Profile edit?
The only problem I see now is that the 'update_member_directory_preference' script isn't updated after registration. Is there a hook that can handle that?
Statistics: Posted by Jason Caldwell — July 8th, 2011, 9:03 pm
Statistics: Posted by Cristián Lávaque — July 8th, 2011, 8:25 pm
Statistics: Posted by nashvillegeek — July 8th, 2011, 11:37 am
add_action('ws_plugin__s2member_after_handle_profile_modifications', 'catch_profile_edit');
function catch_profile_edit() {
global $current_user;
$s2_custom_fields = get_user_field('s2member_custom_fields', $current_user->ID);
if ($s2_custom_fields['member_directory_include'] === '1')
add_user_meta($current_user->ID, '_tern_wp_member_list', 'My List');
else
delete_user_meta($current_user->ID, '_tern_wp_member_list');
}
nashvillegeek wrote:
The only problem I see now is that the 'update_member_directory_preference' script isn't updated after registration. Is there a hook that can handle that?
Statistics: Posted by Cristián Lávaque — July 7th, 2011, 5:53 pm
function get_s2member_custom_fields($user_id = '') {
$values = get_user_option('s2member_custom_fields', $user_id);
foreach ((array)json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], true) as $field)
$custom_fields[$field['id']] = array(
'label' => $field['label'],
'value' => isset($values[$field['id']]) ? $values[$field['id']] : '',
);
return $custom_fields;
}
function update_member_directory_preference($curUser,$custom_fields){
//adjust user meta to adapt to preference
if(($custom_fields['member_directory_include']['value'])=="1") {
add_user_meta($curUser,'_tern_wp_member_list','My List');
}
if(($custom_fields['member_directory_include']['value'])!=1){
delete_user_meta($curUser,'_tern_wp_member_list');
}
}
function catch_profile_edit()
{
global $getWP,$tern_wp_members_defaults,$current_user,$wpdb,$profileuser;
$custom_fields = get_s2member_custom_fields();
$curUser = $current_user->ID;
update_member_directory_preference($curUser,$custom_fields);
}
add_action("ws_plugin__s2member_after_handle_profile_modifications", "catch_profile_edit");
Statistics: Posted by nashvillegeek — July 7th, 2011, 3:27 pm
$s2_custom_fields = get_user_option('wp_s2member_custom_fields', $user_id);
Statistics: Posted by Cristián Lávaque — July 7th, 2011, 2:11 pm
Statistics: Posted by nashvillegeek — July 7th, 2011, 1:50 pm
Statistics: Posted by Cristián Lávaque — July 7th, 2011, 2:15 am
Statistics: Posted by nashvillegeek — July 6th, 2011, 11:51 am