Advertisement
Guest User

Untitled

a guest
May 15th, 2025
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. function disable_metabox_custom_post_get_restapi ($result) {
  3.     global $wp;
  4.  
  5.     if ( true === $result || is_wp_error( $result ) ) {
  6.         return $result;
  7.     }
  8.  
  9.     if ( str_starts_with($wp->request, 'wp-json/wp/v2/custom-post') && ! current_user_can('administrator')) {
  10.         return new WP_Error(
  11.             'wp_auth_error',
  12.             __('Not allowed.'),
  13.             array( 'status' => 403 )
  14.         );
  15.     }
  16.  
  17.     return $result;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement