-
-
Save geotsiokos/a8a4e7e305977344fc12211512c94908 to your computer and use it in GitHub Desktop.
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
function my_affiliates_permanent_my_users( $atts ){ | |
$output = ""; | |
if ( is_user_logged_in() ) { | |
$user = wp_get_current_user(); | |
$args = array( | |
'meta_key' => Affiliates_Permanent::REFERRER, | |
'meta_value' => $user->ID | |
); | |
$users = get_users( $args ); | |
if ( isset( $users ) && ( sizeof( $users ) > 0 ) ) { | |
$output .= '<ul>'; | |
foreach ( $users as $us ) { | |
$output .= '<li>' . $us->user_login . '</li>'; | |
} | |
$output .= '</ul>'; | |
} | |
} | |
return $output; | |
} | |
add_shortcode( 'affiliates_permanent_my_users', 'my_affiliates_permanent_my_users' ); |
Thanks for your reply.
I did take a quick look on function get_user_meta() yesterday and I forgot to write back to you that I've found a solution.
Btw I did some rewriting and added 'role' => 'my role' to use this with different roles. So big thanks for your code.
That's great, I'm glad you resolved this and added further features.
Good to know that my code is useful.
Cheers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're welcome, I'm glad you found this shortcode useful.
That would depend on where this data is stored. If it's in the usermeta table, you can use the function get_user_meta() as described in the Codex:
https://codex.wordpress.org/Function_Reference/get_user_meta.
After fetching the meta you can print all that additional info for the user by appending it to $output.
Hope it helps.
Cheers