[wp-trac] [WordPress Trac] #51748: Allow customization of permission_callback errors

WordPress Trac noreply at wordpress.org
Tue Nov 10 22:52:34 UTC 2020


#51748: Allow customization of permission_callback errors
-------------------------+------------------------------
 Reporter:  plucmtl      |       Owner:  (none)
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  REST API     |     Version:  4.7
 Severity:  normal       |  Resolution:  invalid
 Keywords:  needs-patch  |     Focuses:
-------------------------+------------------------------
Changes (by plucmtl):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Indeed, this achieves the same thing:

 {{{#!php
 add_filter('rest_post_dispatch', function(\WP_HTTP_Response $response){
   // Check if it's a login error
   if ($response->is_error()) {
     $error = $response->as_error();
     // if it is, force it to go through our response filtering
     if ($error->get_error_code() == self::ERR_NOT_AUTHENTICATED) return
 self::respondWith($error);
   }
   return $response;
 });

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51748#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list