How to get userid by url wordpress in userpro plugin?
I am using userPro plugin. My url is below:
(alex is username and i am on profile page i need to get alex in function.php
file)
I have set Mail Name in Permalink settings from admin side
if i set it to Default from permalink parameters then i can get user id and url done this way
if i write $_GET['up_username']
then i get username. I want it with Mail Name in Permalink settings.
+3
source to share
3 answers
This is a combination of the answer I got from @sweet potato, but I included the view_his_profile () function when the logged in user is on the profile page.
Really useful when you want to add some code outside of the userpro templates
Hope it helps
global $userpro;
if ($userpro->viewing_his_profile()) {
debug(get_current_user_id());
} else {
$user = $userpro->get_member_by(get_query_var('up_username'));
debug($user->data->ID);
}
0
source to share