• Resolved Anders Stensaas

    (@saaselina)


    Hi.

    I’m struggling a lot with checking for permissions in the WP REST API v2.
    I’ve created my own plugin where my controllers derives from the WP_REST_Controller. However, when I access some user information, (check if the user is authenticated, get the current user etc.) it’s not set. is_user_logged_in returns false, wp_get_current_user returns only null values. When I access the site base URL and underlying URLs, it works as intended. It’s only in the REST API it doesn’t work.

    Am I doing something wrong here? The user information should be set in my own controllers.

    https://ww.wp.xz.cn/plugins/rest-api/

Viewing 1 replies (of 1 total)
  • Thread Starter Anders Stensaas

    (@saaselina)

    I guess it’s me being stupid. This article clearly states, that cookie authentication is not enough. I’m using the WP OAuth Server plugin to authenticate users by OAuth2.0. WP REST API supports nonce and OAuth authentication. When this authentication mechanism is used, it works like expected. The user object is populated like expected.

Viewing 1 replies (of 1 total)

The topic ‘is_user_logged_in returns false’ is closed to new replies.