Created
April 30, 2017 14:13
-
-
Save alandbh/407b493821cd7eb893012b2acf23174c to your computer and use it in GitHub Desktop.
A complete query go get all users in Wordpress loop with custom fields and date/time.// Uma query completa para pegar todos os usuários cadastrados e montar um loop com data e hora.
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
<?php | |
$args = array( | |
'blog_id' => $GLOBALS['blog_id'], | |
'role' => 'author', | |
'role__in' => array(), | |
'role__not_in' => array(), | |
'meta_key' => '', | |
'meta_value' => '', | |
'meta_compare' => '', | |
'meta_query' => array(), | |
'date_query' => array(), | |
'include' => array(), | |
'exclude' => array(), | |
'orderby' => 'nicename', | |
'order' => 'ASC', | |
'offset' => '', | |
'search' => '', | |
'number' => '', | |
'count_total' => false, | |
'fields' => 'all', | |
'who' => '' | |
); | |
//$pessoas = get_users( 'blog_id=1&orderby=nicename&role=author' ); | |
$pessoas = get_users($args); | |
// Array of WP_User objects. | |
foreach ( $pessoas as $pessoa ) { | |
$id = $pessoa->ID; | |
$login = $pessoa->user_login; | |
$nome_composto = $pessoa->display_name; | |
$nome = $pessoa->user_nicename; | |
$email = $pessoa->user_email; | |
setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese'); | |
date_default_timezone_set('America/Sao_Paulo'); | |
$aniversario = get_field('aniversario', 'user_'. $id ); | |
$aniversarioData = strftime('%d de %B', strtotime($aniversario)); | |
$avatarArr = get_field('avatar', 'user_'. $id ); | |
$avatarTbn = $avatarArr['sizes']['thumbnail']; | |
$funcoes = get_field('funcao_no_synergia', 'user_'. $id ); | |
$_funcao = ''; | |
$count = 1; | |
foreach ($funcoes as $funcao) { | |
$qtd = count($funcoes); | |
if ($count < $qtd ) { | |
$_funcao .= $funcao['label'] . ' / '; | |
} else { | |
$_funcao .= $funcao['label']; | |
} | |
$count++; | |
} | |
echo '<p>' . esc_html( $pessoa->user_email ) . '</p>'; | |
echo '<p>' . $aniversarioData . '</p>'; | |
echo '<p>' . $avatarTbn . '</p>'; | |
echo '<p>' . $_funcao . '</p>'; | |
echo '<p>' . $login . '</p>'; | |
echo '<pre>'; | |
print_r($_funcao); | |
echo '</pre>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment