question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Correct way to check if user is logged in and perform a ".me()" request

See original GitHub issue

Hi there,

Just wanted to check/confirm:

Is there a way, whilst only using wpapi, to check whether the wp.users().me() request can be performed?

If the user is not logged in, but a call to wp.users().me() is made, then the response is 403, but I’d like to be able to check if the user is logged in before making the wp.users().me() call.

Currently I’m wrapping the call in this:

if (document.body.classList.contains('logged-in')) {
  //Make call
}

But it seems like an awful way to do it…!

Any advice on this would be great 👍

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
kadamwhitecommented, Jul 6, 2017

Glad to hear it helps, happy coding!

0reactions
kadamwhitecommented, Jun 27, 2018

@barath-prakash Menus are not available through the REST API yet. I’m going to have to ask you to please stop using these issues for support requests; I’m glad you’re using the API and that you tried this library, but GitHub issues are not an appropriate place for the sorts of general questions you have been raising. Please use the WordPress.org support forums.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to check if a user is logged in (how to properly use user ...
For Django 1.9 and older. is_authenticated is a function. You should call it like if request.user.is_authenticated(): # do something if ...
Read more >
How to check user is logged in or not. - ServiceNow Community
This is handled by the sys_user_token and sys_user_session. Scenario 1 - The user receives a link and their session has timed out. The...
Read more >
How to Check if a User is Logged In with React - YouTube
This React JS tutorial shows how to check to see if a user is logged in each time they access the application. We...
Read more >
I want to know how to check if users are logged in
For example, in Laravel, we can use Auth::check() to check if the user is logged in. How do I implement this in my...
Read more >
Get a user - Microsoft Graph v1.0
To learn more, including how to choose permissions, see ... Application permissions are not supported when using the /me endpoint. The User.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found