Last active
December 28, 2015 04:29
-
-
Save jg314/7442631 to your computer and use it in GitHub Desktop.
Display all the board members for the Nonprofit Board Management plugin using a shortcode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Display all the board members for the Nonprofit Board Management plugin | |
* using a shortcode. | |
* | |
* Copy and paste this code into your functions.php file to use it. | |
* | |
* example for use on a page: [list_board_members] | |
*/ | |
function wi_list_board_members(){ | |
//Get all the board members | |
$board_members = get_users( array( 'role' => 'board_member' ) ); | |
$board_member_html = '<div class="board-members">'; | |
//Loop through all the board members and output their info | |
foreach( $board_members as $board_member ){ | |
//Put every board member in its own div for easier styling | |
$board_member_html .= '<div class="board-member">'; | |
//Store user meta information to use below for display | |
$phone = get_user_meta( $board_member->ID, 'phone', true ); //Store phone | |
$employer = get_user_meta( $board_member->ID, 'current_employer', true ); //Store current employer | |
$job_title = get_user_meta( $board_member->ID, 'job_title', true ); //Store job title | |
//Add the HTML to display for the screen | |
//Edit this to display the information in a different order or remove info | |
$board_member_html .= get_avatar( $board_member->ID, '44' ); //Gravatar photo | |
$board_member_html .= '<h3>' . $board_member->display_name . '</h3>'; //Display name | |
$board_member_html .= '<div class="phone">Phone: ' . $phone . '</div>'; //Phone number | |
$board_member_html .= '<div class="job-employer">' . $job_title . ', ' . $employer . '</div>'; //Job and employer | |
$board_member_html .= '</div><!-- /.board-member -->'; | |
} | |
$board_member_html .= '</div><!-- /.board-members -->'; | |
return $board_member_html; | |
} | |
add_shortcode( 'list_board_members', 'wi_list_board_members' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This functionality is now built in to the plugin. There is no need to use this shortcode.