$like = '\"ref_id\"\;s:' . strlen($user) . ':\"' .$user. '\"';
$query = 'SELECT user_id FROM wp_usermeta WHERE meta_key = "wp_s2member_custom_fields" AND meta_value LIKE "%' . $like . '%"';
echo mysql_num_rows(mysql_query($query));
Statistics: Posted by Cristián Lávaque — April 19th, 2011, 10:10 pm
s:6:"ref_id";s:1:"1";
// $user comes from the function($user) variable
//I started the string at the opening " of the custom field name and ended it before the required character length of the value.
//I also comment out the " and the ; to make sure it doesn't mess up the query.
$value = '\"ref_id\"\;s:';
//I used this to get the character length of the $user or value I am searching for.
$length = strlen($user);
//Add the character length to the query string
$value .= $length;
// finish up the query string.
$value .= ':\"'.$user.'\"';
//Use the LIKE %% to search inside the serialized fields.
$sql = 'SELECT user_id FROM wp_usermeta WHERE meta_key = "wp_s2member_custom_fields" AND meta_value LIKE "%'.$value.'%"';
// I'm just looking for a total but you could use the query to print out a list or whatever.
$total = mysql_num_rows(mysql_query($sql));
$value = '\"ref_id\"\;s:';
$length = strlen($user);
$value .= $length;
$value .= ':\"'.$user.'\"';
$sql = 'SELECT user_id FROM wp_usermeta WHERE meta_key = "wp_s2member_custom_fields" AND meta_value LIKE "%'.$value.'%"';
$total = mysql_num_rows(mysql_query($sql));
echo $total;
Statistics: Posted by dwbiz05 — April 19th, 2011, 4:45 pm
Statistics: Posted by dwbiz05 — April 19th, 2011, 4:05 pm
$user = get_userdata($user_id);
$custom_fields = get_user_option('s2member_custom_fields', $user_id);
$fruitArray = (array) $custom_fields['favorite-fruit']
$fruitList = implode(',', $fruitArray)
Statistics: Posted by dwdutch — January 16th, 2011, 11:24 am