Skip to content

Right way to call wp.users().me() #206

@wblaircox

Description

@wblaircox

After 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!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions