-
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 triedget_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.
In the templates (view.php/edit.php) the user id is stored in $hook_args array i.e $hook_args[‘user_id’] .
Thank You!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.
Thanks for posting the solution to your own question! The internet needs more of this.
You must be logged in to reply to this topic.