Skip Navigation

[Résolu] user info

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.

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

Last updated by Luit Il y a 8 années.

Assigned support staff: Luo Yang.

Auteur
Publications
#169309

I use this code to get the name of a specific user:
add_shortcode('wpv-user', 'my_user_shortcode');
function my_user_shortcode($atts, $content = null) {
global $WP_Views, $current_user;
$WP_Views->users_data['term'] = get_userdata($atts['id']);
return wpv_user($atts);
}

But how to get the other information like e-mailaddress.

#169950

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Luit,

Are we talking about a custom user field, created with Types, and using slug "e-mailaddress"?
Please try types function types_render_usermeta_field
More help:
https://toolset.com/documentation/user-guides/displaying-wordpress-user-fields/

#169955

no I want the e-mailaddress of a specific user, not a custom field

#170003

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I assume you are using the shortcode in your content like this:
[my_user_shortcode id=123]
123 is the specific user user's ID
Please try create a custom shortcode like this:

add_shortcode('specific-user-email', 'specific_user_email_func');
function specific_user_email_func($atts, $content = null) {
	$user_obj = get_userdata($atts['id']);
	$res = '';
	if($user_obj)
	{
		$res = $user_obj->user_email;
	}
	return $res;
}

put the shortcode into your content, like this:
[specific-user-email id=1]

#170115

Thanks Luoy, that works great