Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Current User ID #30

Open
stevegiorgi opened this issue Apr 14, 2021 · 1 comment
Open

Get Current User ID #30

stevegiorgi opened this issue Apr 14, 2021 · 1 comment

Comments

@stevegiorgi
Copy link

How do we go about getting the current user id? Do we need set a request header with X-WP-Nonce? Any examples would be awesome.

@noogen
Copy link

noogen commented Jul 17, 2021

You can use get_current_user_id with wp_localize_script to output the data on the page. If you generate a nonce with wp_create_nonce then the user would be authenticated by passing in the X-WP-Nonce header and then you can use get_current_user_id in your WP_REST_Controller handler.

Also see #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants