Get a field of the displayed user, without logging in – UserPro Forums https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/feed/ Tue, 07 May 2024 00:37:43 +0000 https://bbpress.org/?v=2.6.2 en-US https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-43115 <![CDATA[Get a field of the displayed user, without logging in]]> https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-43115 Wed, 01 Oct 2014 19:45:06 +0000 Patchin Hello!

What I’m trying to do is quite simple, but I just don’t know what’s preventing me from doing it.

You see, I’m trying to launch, right on the profile page, a PHP function (using a plugin such as “Insert PHP”) of a map, for which I need pass on the address that the user has entered. To sum it up, I just need the field “address” of the user that’s DISPLAYED, not the user that’s logged in.

I’ve read the code documentation, and it seemed that the function userpro_profile_data( $field, $user_id ); was the one that I was looking for. $field would be ‘address’… but how do I get $user_id ?? I’ve tried get_current_user_id();, but that returns the ID of the user that is logged in, not the one that I’m viewing.

I’m guessing that, if I’m able to solve this, I’ll also be able to manage content based on roles, which I’ll have to in the future. So this would really really help me out.

]]>
https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-43216 <![CDATA[Reply To: Get a field of the displayed user, without logging in]]> https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-43216 Mon, 06 Oct 2014 19:31:20 +0000 Patchin Anyone, please? I’m sure it’s really not that hard to do.

]]>
https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-43249 <![CDATA[Reply To: Get a field of the displayed user, without logging in]]> https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-43249 Wed, 08 Oct 2014 09:33:43 +0000 UserPro Support Team In the templates (view.php/edit.php) the user id is stored in $hook_args array i.e $hook_args[‘user_id’] .
Thank You!

]]>
https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-43254 <![CDATA[Reply To: Get a field of the displayed user, without logging in]]> https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-43254 Wed, 08 Oct 2014 10:55:48 +0000 Patchin Thank you for your reply. Better late than never!

Although it’s useful information, and may come in handy in the future, it’s not what I was looking for. Perhaps I didn’t make myself clear. What I was trying to do is catch a field of a user inside the page, and what I meant by page was post, not template. To do so, I was using Insert PHP, although there are lots of plugins that do the same thing.

But, just now, 5 minutes ago, I’ve come up with the solution, FINALLY. The api.php file had more than I could imagined. Inside the PHP tags of the plugin mentioned above, I wrote the following code:

global $userpro;
$user_id = $userpro->get_member_by_queryvar_from_id();
$address = userpro_profile_data( address, $user_id );
echo $address;

And voilà! I can now access any field I want, and I can progress much more and much faster.

]]>
https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-46441 <![CDATA[Reply To: Get a field of the displayed user, without logging in]]> https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-46441 Sat, 07 Mar 2015 19:20:59 +0000 Michael Davies Thanks for posting the solution to your own question! The internet needs more of this.

]]>
https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-46489 <![CDATA[Reply To: Get a field of the displayed user, without logging in]]> https://forum.userproplugin.com/forums/topic/get-a-field-of-the-displayed-user-without-logging-in/#post-46489 Tue, 10 Mar 2015 07:33:36 +0000 NDJSupport Thanks Patchin for posting the solution 🙂

]]>