helpful/api/options

This filter allows you to manipulate the default Helpful endpoint options in the WordPress REST API.

By default, an empty string is output for the permission_callback, so you don’t need to be an administrator to get the data with the API.

In the following example you will learn how only editors or administrators can use the API, regardless of whether they have an application password for the API or not:

/**
 * @param array $options
 * @return array
 */
add_filter('helpful/api/options', function ($options) {

    $options['permission_callback'] = function () {
        return current_user_can( 'edit_others_posts' );
    };

    return $options;
});
Was this post helpful?
Top