Posted by Simon Goodchild at May 13th, 2012
You may want to include certain “meta” information for each member on the directory, and it’s quite easy to do.
Recommended for v13.02 (release candidate 23+) of WP Symposium or higher.
First, add the following to your functions.php file to show the common WP Symposium member information you can show, and how to show your extended fields. For your extended fields, you use the slugs that you’ve set on the WPS Profile admin page (extended fields section). In the example below, I’m referring to a slug called ‘gender’.
Note that the second parameter of add_filter matches the function name below.
add_filter( '__wps__directory_member_filter', 'wps_extra_info', 10, 2 );
function wps_extra_info( $html, $uid ) {
global $wpdb;
// Include the WPS User class
require_once(WP_PLUGIN_DIR.'/wp-symposium/class.wps_user.php');
$wps_user = new wps_user($uid);
// Start the additional content (in a DIV)
$add = '<div>';
// Eexamples of core user information
$add .= 'Date of birth: '.$wps_user->get_dob_day().'/'.$wps_user->get_dob_month().'/'.$wps_user->get_dob_year().'<br />';
$add .= 'City: '.$wps_user->get_city().'<br />';
$add .= 'Country: '.$wps_user->get_country().'<br />';
$add .= 'Email: '.$wps_user->get_user_email().'<br />';
$add .= 'Display name: '.$wps_user->get_display_name().'<br />';
$add .= 'User login: '.$wps_user->get_user_login().'<br />';
$add .= 'Latest activity: '.$wps_user->get_latest_activity().'<br />';
// Gender (example of an extended field, with 'gender' slug)
$gender = $wps_user->get_user_meta($uid, 'extended_gender');
$add .= 'Gender: '.$gender.'<br />';
// End the additional content (the DIV)
$add .= '</div>';
// Return the sent content, plus the additional content
return $html.$add;
}
Here’s a screenshot:
Category: Tutorials





Saving...
Leave a Reply