I am aware that I can get current user details via [wpv-current-user].
Is it possible to get data relating to a specific user by adding a user id?
What I want to do is create a password protected page whereby selected people can see email addresses of all registered users.
Thanks
Tony
My alternative solution invoves setting up a subscriber post and dupicating the fields that I want access to
Dear tony,
You need to use some codes and a shortcode to do this. Please take a look in this page, it's a default wordpress function and with it you can to display all users with its data: http://codex.wordpress.org/Function_Reference/get_users#Example
ok thanks Adriano (sorry for the delay - been looking at other solutions!
I have had a look at this and cannot work out what exactly I need to do.
I have a member record that contains the user-id that relates to the member. Ideally what I want to do is to create a view that returns a list of "memberships" That record contains user-id and member-id amongst other fields.
I would like to display a list of memberships that includes data from members and users. So my report would look something like:
member name {from user data} | email {from user data} | member status {from member data} | joining date {from member data
If I create a parent/child relationship between membership and member, I can get all the member fields. I just need to get the user data fields using shortcodes.
Maybe something like [wpv-user info="email" id="2345"] and [wpv-user info="firstname" id="2345"] [wpv-user info="surname" id="2345"]
( id="2345" relates to the user and is a field in the membership record)
Thanks
Tony
Dear tony,
I created a custom shortcode for this, please try with it and let me know about the result. Put the code below inside of functions.php file:
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);
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);
}
}
As you can see, this custom shortcode will woks only for to get the email, firstname and lastname. So you can use [wpv-post-userdata field_user="user_firstname" id_user="123"]
You will need to use the correct name so, you can see its here: http://codex.wordpress.org/Function_Reference/get_userdata#Notes
I hope that's help you.
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Thanks Adriano
The user ID is defined by this types field: [types field="member-user-id" id="$member"][/types]
Am I right in thinking that I can replace the "123" in your shortcode with this to create:
[wpv-post-userdata field_user="user_firstname" id_user="[types field="member-user-id" id="$member"][/types]"]
[wpv-post-userdata field_user="user_firstname" id_user="123"]
Tony
Hi Adriano
I tried this and something seems to be wrong.
The function.php has been uploaded and I tried a simple field [wpv-post-userdata field_user="user_firstname" id_user="2"] which did not return anything.
Tony
Dear tony,
Please replace your code with:
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);
if($field_user == 'user_email'){
echo($user_info->user_email);
}
if($field_user == 'user_firstname'){
echo($user_info->user_firstname);
}
if($field_user == 'user_lastname'){
echo($user_info->user_lastname);
}
}
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Hi Adriano
Many thanks for this.
I changed the functions.php and set the following up on my home page as a test:
Details of users<br />
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"]<br />
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"]<br />
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"]<br />
I have 3 users set up 1,2 and 3.
The resulting display was:
Details of users
1=
2=
3=
In theory, this code should work in any WordPress system that has users 1,2 and 3 set up with the function.php code in place.
I cannot see what might be wrong.
Regards
Tony
Dear tony,
I’ll send you a private email right now asking you for some private information that will help me debug this issue for you. Please check your email in a couple of minutes, and if you don’t get it, let me know so I can send it again.
Thanks.
Thanks Adriano
Details sent.
Tony
Dear tony, I'm trying to save the funcions.php file and I can not. Please send me the FTP credentials too.
Many thanks.
Hello Adriano
Details sent by email
Tony
Dear tony,
Thanks, I received the credentials and I'm checking it now.
Dear tony,
I change the shortcode codes and now it works fine. Please check the post named "Test" and the functions.php file.
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Thanks Adriano
That seems to work fine and so I can now construct a membership list that takes data from the user details as well as member details.
Excellent response as per normal.
Regards
Tony