Skip Navigation

[Résolu] Views – get user data via a user-id

This support ticket is created Il y a 9 années et 10 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 22 réponses, has 4 voix.

Last updated by tony Il y a 9 années.

Assigned support staff: Adriano.

Auteur
Publications
#88854

You are welcome.

#107536

Hi there - I need to do something very similar but because the conclusion of this took place offline I can't see the final function - would be great if you could share the code Tony. Thanks!

#107609

Simon

The code that is in my functions.php file is:

add_shortcode( 'wpv-post-userdata', 'wpv_userdata');
function wpv_userdata($atts){
extract( shortcode_atts( array(
'field_user' => '',
'id_user' => '',
), $atts ) );

$user_info = get_userdata($id_user);

if($field_user == 'user_email'){
return($user_info->user_email);
}
if($field_user == 'user_firstname'){
return($user_info->user_firstname);
}
if($field_user == 'user_lastname'){
return($user_info->user_lastname);
}
}

I hope this helps.

Tony

#107616

Much obliged Tony - could you also confirm how the shortcode should look in the post? thank you 🙂

#107620

OK I have not completed my implementation, but this was used as a test:

Details of users

1=[wpv-post-userdata field_user="user_firstname" id_user="1"] [wpv-post-userdata field_user="user_lastname" id_user="1"] [wpv-post-userdata field_user="user_email" id_user="1"]

2=[wpv-post-userdata field_user="user_firstname" id_user="2"] [wpv-post-userdata field_user="user_lastname" id_user="2"] [wpv-post-userdata field_user="user_email" id_user="2"]

3=[wpv-post-userdata field_user="user_firstname" id_user="3"] [wpv-post-userdata field_user="user_lastname" id_user="3"] [wpv-post-userdata field_user="user_email" id_user="3"]

4=[wpv-post-userdata field_user="user_firstname" id_user="4"] [wpv-post-userdata field_user="user_lastname" id_user="4"] [wpv-post-userdata field_user="user_email" id_user="4"]

Tony

#107638

Superb, many thanks

#186396

Hi, could you post the final custom function please ?

#186467

Matthieu

The code I used is displayed above (June 26, 2013 at 11:16 am).

I hope this helps.
Tony