WP-API: how do I allow authenticated clients only?

This is how I did it, but I feel it could be better. For one thing, this results in HTTP 500… 403 would be preferable

add_filter( 'json_authentication_errors', function( $authenticated ) {
    if( !$authenticated ) {
        return new WP_Error('Access Denied');
    }
}, 99 );

(I understand this’ll work for Basic Auth too)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)