New answers tagged

0

Use the register_rest_route() function. if( current_user_can( 'read_addresses' ) ) { register_rest_route( 'namespace/v1', 'cpt', array( 'methods' => array( 'GET' ), 'callback' => 'callback_function', 'permission_callback' => 'permission_callback_function' ) ); } Your callback_function would handle the request and ...


0

Don't rely solely on hiding it. Instead, return an error in the handler: if (!current_user_can('read_addresses')) { return new WP_REST_Response('restricted', 403); } To hide it as well, filter the content of the hooks rest_index and rest_namespace_index.


1

Yes, there is a function in WP for that: wp_check_post_lock() Give it the post ID and it will return the user ID that is currently editing the post OR false if no one is editing the post (i.e. it is not locked). $is_locked = wp_check_post_lock( $post_id ); if ( false === $is_locked ) { // Post $post_id is not not locked for editing } else { //...


Top 50 recent answers are included