Created
May 3, 2017 13:08
-
-
Save Hotfirenet/52b8ae65ad3003c8e823b5744d439b40 to your computer and use it in GitHub Desktop.
Shortcode wordpress qui permet de lister les utilisateurs et d'afficher uniquement ceux qui ont un email avec le domaine voulu.
This file contains 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
// Use [collaborateurs][/collaborateurs] | |
add_shortcode( 'collaborateurs', function () { | |
$search = "/@hotfirenet\.com$/i"; | |
$html = '<div id="collaborateurs" class="items">'; | |
//$users = get_users(); | |
$args = array( | |
'field' => 'all_with_meta' | |
); | |
$users_query = new WP_User_Query( $args ); | |
$users = $users_query->get_results(); | |
foreach ($users as $user) { | |
if(!preg_match($search, $user->user_email)) | |
continue; | |
// variables dispo | |
// $user->ID | |
// $user->user_login | |
// $user->user_nicename | |
// $user->user_email | |
// $user->user_url | |
// $user->display_name | |
// Avatar | |
// echo get_avatar( $user->user_email, 96 ); | |
// echo get_avatar_url( $user->user_email ); | |
$user_info = get_userdata($user->ID); | |
// $user_info->first_name; | |
// $user_info->last_name | |
// $user_info->nickname | |
// $user_info->description | |
// $user_info->author_facebook | |
// $user_info->author_twitter | |
// .... | |
ob_start(); | |
get_template_part( 'template-parts/collaborateur/content' ); | |
$html .= ob_get_clean(); | |
} | |
$html .= '</div>'; | |
return $html; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment