Correct way to check if user is logged in and perform a ".me()" request
See original GitHub issueHi 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:
- Created 6 years ago
- Comments:12
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Glad to hear it helps, happy coding!
@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.