latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

About: Todd Mosher

Sorry, I've not written a description yet. I'll get to it soon!


Topics I'm Subscribed To

Viewing 2 topics - 1 through 2 (of 2 total)
Topic Count Last Reply
Custom s2Member User Profile

By:  Todd Mosher in: Community Forum

voices: 2
replies: 1

3 years, 10 months ago  Bruce

Copying user profile fields to other fields

By:  Todd Mosher in: Community Forum

voices: 2
replies: 2

3 years, 11 months ago  Jason (Lead Developer)

Viewing 2 topics - 1 through 2 (of 2 total)

Topics I've Started

Viewing 2 topics - 1 through 2 (of 2 total)
Topic Count Last Reply
Custom s2Member User Profile

By:  Todd Mosher in: Community Forum

voices: 2
replies: 1

3 years, 10 months ago  Bruce

Copying user profile fields to other fields

By:  Todd Mosher in: Community Forum

voices: 2
replies: 2

3 years, 11 months ago  Jason (Lead Developer)

Viewing 2 topics - 1 through 2 (of 2 total)

My Latest Replies (From Various Topics)

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Friday Jan 25th, 2013 at 11:49 am #39518
Todd Mosher
Username: jczone5

More information on my post.. here are the pertinent sections of my script (bootstraps WP first):

/** Loads the WordPress Environment and Template */
require($_SERVER[‘DOCUMENT_ROOT’].’/wp-load.php’);

/* Grab all of the user ID’s minus Administrator accounts whose ID’s are lower than 5 to query
* the user_meta table
*/
$user_query = “SELECT ID FROM {$wpdb->prefix}users WHERE ID > 5″;
$user_res = mysql_query($user_query) or die(mysql_error());
$userIDs = array();
while ($userIDs = mysql_fetch_object($user_res)) {
$userID[] = $userIDs->ID;
}

/* loop through the userID array and construct a query to pull all s2member profile field
* data.
*/
for ($i=0; $iprefix}usermeta um INNER JOIN {$wpdb->prefix}users u ON u.ID = um.user_id WHERE meta_key = ‘wp_s2member_custom_fields’ AND user_id = ‘$tmp_user_id'”;
$res = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_object($res);
// serialized s2member custom fields row
$serialized = $row->meta_value;
$user_email = $row->user_email;
// array containing the unserialized string data from wp custom fields
$user_array = unserialize($serialized);

// create array placeholder for sanitized user data
$sanitized_user_array = array();

// loop through all user data and escape ‘s
foreach ($user_array as $k => $v) {
$sanitized_user_array[$k] = addslashes($v);
}

// create array for new “internal use only” s2member profile fields
$address = array(
‘rc_mailing_address’ => addslashes($user_array[‘address1’]),
‘rc_mailing_address_2’ => addslashes($user_array[‘address2’]),
‘rc_city’ => addslashes($user_array[‘city’]),
‘rc_state’ => $user_array[‘state’],
‘rc_zip’ => $user_array[‘zip’],
‘rc_email_address’ => $user_email,
‘rc_phone’ => $user_array[‘phone_1’],
‘rc_fax’ => $user_array[‘phone_2’],
);

// merge the sanitized array with escaped internal use only array for insert
$new_array = array_merge($sanitized_user_array, $address);
// re-serialize merged wp custom fields array for insert
$new_serialize = serialize($new_array);

// construct query for updating wp custom fields with new merged array
$insert_query = “UPDATE {$wpdb->prefix}usermeta SET meta_value = ‘”.$new_serialize.”‘ WHERE user_id = ‘$tmp_user_id’ AND meta_key = ‘wp_s2member_custom_fields'”;

$insert_res = mysql_query($insert_query) or die(mysql_error());
}

Viewing 1 replies (of 1 total)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.