[wp-trac] [WordPress Trac] #39820: Can't change header status code response
WordPress Trac
noreply at wordpress.org
Thu Feb 9 09:39:04 UTC 2017
#39820: Can't change header status code response
--------------------------+------------------------------
Reporter: skarabeq | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.7.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by Compute):
You should be able to send arguments to wp_die(). Response code can be
sent to the title argument.
See [https://developer.wordpress.org/reference/functions/wp_die/] and
https://developer.wordpress.org/reference/functions/wp_die/
{{{
if ( is_int( $args ) ) {
$args = array( 'response' => $args );
} elseif ( is_int( $title ) ) {
$args = array( 'response' => $title );
$title = '';
}
}}}
So if you use:
{{{
wp_die( '', 422 );
}}}
Or
{{{
wp_die( 'Message', 'Title, array( 422 ) );
}}}
You should be able to change the response code.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39820#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list