• Hi,

    I’d like to use get_current_user_id() in content-course.php to know what user is connected when looping my courses.

    But the problem is that the function always returns 0.

    I noticed that this is because there is no WordPress header on top of the ‘Courses’ page even when a user is logged in on my website (as it would be the case with any other Learnpress page) :

    The function must then consider that no user is logged in at all and return 0.

    Is there a way to properly retrieve the current user ID on the courses page? (https://www.clubhouse-tennis.fr/formations/)

    – Grégoire

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support brianvu-tp

    (@briantp)

    Hi,

    Our developer checked and the function above can get the id of the user logged normally.

    Thread Starter gregclubhouse

    (@gregclubhouse)

    Thanks for your answer.

    Did you try when connected with an admin account?

    Because myself too, I can get the ID of the user logged when I test it with my admin account (in that case, the WordPress header appears on top of the page).

    But if I try to do it by connecting manually to another account, the function always returns 0 because it considers that the user is not logged in.

    Is it normal that I don’t see the WordPress header on top of the courses page when connected with a non-admin account?

    Plugin Support brianvu-tp

    (@briantp)

    Hi,

    You should try to remove the cache and disable all cache folder if have. We checked with the admin, user and it works.

    Thread Starter gregclubhouse

    (@gregclubhouse)

    Yes, I already tried to remove the cache.

    If the user is already logged in, it temporarly displays the WordPress header correctly and so the function returns his correct ID, but if the user disconnects and then reconnects (or just if any other user logs in), the same problem happens again : no WordPress header and ID = 0.

    To me, the main issue comes from this WordPress header not showing up on the courses page (it’s the only page that behaves like this).

    Is it a normal behaviour? Maybe I just need to change some settings so that the header always shows up?

    It seems a bit tedious to have to clear cache every time a user logs in…

    Plugin Support brianvu-tp

    (@briantp)

    If you use the cache plugin, you need disable cache of user logged, you can try to disable LearnPress and check on another page, you will view the same issue

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get current user id on courses page’ is closed to new replies.