Right way to call wp.users().me()
See original GitHub issueAfter nearly two weeks of trying to get WP-API working for my simple project/use, I’ve landed here thanks to @kadamwhite. I’m running a simple JS app within a Wordpress page. I want to save data specific to the logged-in user to the database. Using WP-API is ideal for this in my case. I’m nearly there, finally! Except for that bloody infuriating authentication again. I’m accessing draft/private posts.
So, how exactly do I;
function getPosts() {
//wp.users().auth("USER","PASS").me();
wp.posts().users().me().context('edit').param('status', 'draft').then(function (posts) {
console.log(posts);
});
};
But make sure the current WP User is authenticated? wp.users().me() looks about right, but what is the correct method?
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
WordPress User Roles | Inviting Users | WordPress.com Support
This guide will explain how you can invite other contributors to work on your website with you, using the Users area of your...
Read more >How to Create and Manage Custom WordPress User Roles
2. Create, Edit or Delete WordPress User Roles Manually · add_role(): For adding a custom role. · remove_role(): For removing a custom role....
Read more >How to Add New Users and Authors to Your WordPress Blog
There are 3 ways to add new users to your WordPress website. You can add users ... The best way to do this...
Read more >How to get current logged in user using Wordpress Rest Api?
add_action('rest_api_init', function () { register_rest_route( 'custom', '/login', array( 'methods' => 'GET', 'callback' => function(WP_REST_Request $request) { ...
Read more >How to Edit & Customize User Roles in WordPress
Step 1: Select Users > User Role Editor in the left panel. Step 2: In the right-side button pane, choose Add Role. Step...
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
@wblaircox I’d check out register_rest_field to ensure those fields get included in the returned JSON. Hope that helps!
@wblaircox we’ve got a guide in progress that’ll help you out a lot, I’m slammed with day job rn but will try to get it online within the next day.