• Hello,

    I have a website which when I use get_current_user_id() it return a 0, it doesn’t happen on other site, any clues of what it can be ?!

    Thanks for the help

    J

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi

    Try

    
    $current_user = wp_get_current_user();
    
    $current_user=$current_user->user_login;
    
    

    All the best !

    Thread Starter jcousin

    (@jcousin)

    Thanks for your help but it doesn’t work.

    The strangest thing is that in the homepage it works perfectly, but when I go on the user profile from ultimate member it’s doesn’t. I haven’t had any problem with this plugin and I try to deactivated every plugin and to use a normal theme, but still happen.

    Anyone please ?

    Thanks again

    Hi

    You should have mentioned you’re using the Ultimate Member plugin.

    
    //This will retrieve the current profile user ID in Ultimate Member 
    
    $profile_id = um_profile_id();
    

    If you want to display other User info , like the current user login

    
    $user_info = get_userdata($profile_id);
    $user_login_name=$user_info->user_login;
    echo $user_login_name;
    

    All the best!

    Hi again,

    If you want to retrieve the data of the logged in user

    um_user(‘ID’); can be used instead of um_profile_id();

    Let me know if this works for you ??

    You may also want to read up and experiment with um_user(); as I am sure there’s a nifty way to call up the user’s info.

    it should be um_user($key);

    Perhaps someone with more UM experience can chime in ??

    Thread Starter jcousin

    (@jcousin)

    THanks for the answer, I reinstal everything and it’s working, I don’t what’s happen.

    Thank a lot again

    J

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘get_current_user_id return 0’ is closed to new replies.