
This is what worked for me, by inserting the code into Functions.php
in admin dashboard, inside post, I type in short code like this:
[get_all_user_fields post_field=”user_aim” ], and i get all profile fields shown on front end. Hope this will help someone else.
}
if(! function_exists(‘get_all_user_fields_func’)) {
function get_all_user_fields_func( $atts ) {
extract( shortcode_atts( array(
‘post_field’ => ‘user_aim’,
), $atts ) );
$fieldsList = array(
“first_name” => “First Name”,
“last_name” => “Last Name”,
“text_aim” => “AIM”
);
$postId = get_the_ID();
$customFields = get_post_custom($postId);
if (isset($customFields[$post_field])) {
$userID = $customFields[$post_field][0];
}
else {
$userID = 0;
}
// The Query
$user_query = new WP_User_Query( array( ‘include’ => array( $userID ) ) );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
foreach ( $fieldsList as $fieldName => $fieldLabel) {
$user_field = get_user_meta($userID, $fieldName);
if (isset($user_field[0])) {
$fieldValue = $user_field[0];
$out .= “<b>$fieldLabel<b>: «$fieldValue» <br/>”;
}else {
$out .= “<b>$fieldLabel<b> is not filled <br/>”;
}
}
}
} else {
$out = ‘No users found at all.’;
}
return $out;
}
add_shortcode( ‘get_all_user_fields’, ‘get_all_user_fields_func’ );
}
to onesizeup, Thank you for sending the link about WP_User_Query, I just checked and will experiment and post back with my results. I appreciate your effort ! Good day to you !
Ed