Advertisement
NubeColectiva

Como Deshabilitar la API REST de WordPress con PHP

May 10th, 2024
729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | Software | 0 0
  1. /* Deshabilitar API REST en WordPress */
  2. /* Colócalo en el archivo functions.php de tu Tema */
  3.  
  4. add_filter('rest_authentication_errors', function($resultados) {
  5.     if (true === $resultados || is_wp_error($resultados)) {
  6.         return $resultados;
  7.     }
  8.  
  9.     if (! is_user_logged_in()) {
  10.         return new WP_Error(
  11.             'mi_codigo',
  12.             __( 'No tienes permiso para ver esto.' ),
  13.             array( 'status' => 401 )
  14.         );
  15.     }
  16.  
  17.     return $resultados;
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement