Ok, so I have been tearing my hair out. I found this thread from back in April: http://www.s2member.com/forums/topic/get-custom-profile-field-values/
I read through that and all the sub links within it. Basically on my site, I am using the members-list plugin that has been recommended a few times on here, and if you click on the name of the user it will take you to the author.php page which outputs the data in their profile to the public (someone who can be logged in or out).
I have 3 custom fields that are multi-select boxes. When I use the following code in my author.php file:
<ul>
<li><?php echo get_user_field('profile_disciplines', $thisauthor->ID); ?></li>
</ul>
Nothing prints out. So Reading around the forums and other links on here on how to get an array to print out I referenced this link: http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_get_s2member_custom_fields%28%29
When I use the following code in my author.php file:
<?php
$fields = get_s2member_custom_fields();
print_r($fields["profile_disciplines"]["config"]); # The Unique Field ID you configured with s2Member.
?>
It returns a very messy output that looks like:
Array ( [config] => Array ( [section] => yes [sectitle] => IAPSC Profile [id] => profile_disciplines [label] => Disciplines/Expertise/Services [type] => checkboxes [deflt] => [options] => Competitive Intelligence, Counterespionage, etc.|Competitive Intelligence, Counterespionage, etc. Emergency Planning/Disaster Recovery|Emergency Planning/Disaster Recovery Expert Witness/Forensic & Litigation Support|Expert Witness/Forensic & Litigation Support Fire/Life Safety|Fire/Life Safety Information Security|Information Security Loss Prevention / Shoplifting|Loss Prevention / Shoplifting Master Plans|Master Plans Security Design, Systems & Technology|Security Design, Systems & Technology Security Operations (personnel, policies, etc.)|Security Operations (personnel, policies, etc.) Security Risk Assessments|Security Risk Assessments Terrorism / Counter Terrorism|Terrorism / Counter Terrorism Threat and Crime Analysis|Threat and Crime Analysis Training|Training Workplace Violence|Workplace Violence [expected] => [required] => no [levels] => all [editable] => yes [classes] => [styles] => [attrs] => ) )
Now when I try the following:
<?php
function get_s2member_custom_fields($user_id = $theUserID) {
$return = array();
$user = get_user_option('s2member_custom_fields', $user_id);
foreach ((array)json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], true) as $field) {
if (isset($user[$field['id']])) {
$return[$field['id']]['label'] = $field['label'];
if (empty($field['options']))
$return[$field['id']]['value'] = $user[$field['id']];
else {
$field['options'] = strpos($field['options'], "\n") ? explode("\n", $field['options']) : (array)$field['options'];
foreach ($field['options'] as $option) {
$option = explode('|', $option);
$options[$option[0]] = $option[1];
}
foreach ((array)$user[$field['id']] as $choice)
$return[$field['id']]['options'][$choice] = $options[$choice];
}
}
}
return $return;
}
$s2_custom_fields = get_s2member_custom_fields($theUserID);
echo $var['profile_disciplines']['options'][0]['label'];
?>
It just returns a blank white page (assuming a PHP error, which is what Cristian said in his last post on the link to the original thread I posted. The Original poster never replied back saying he got it to work or not. I just want my custom registration field that is multi checkbox field to output as a unordered list. Can anyone please help me with this!
Thank You!