[wp-hackers] Custom post publish: show error $notice in stead of update $message
Barry Ceelen
barry at multipop.org
Tue Nov 16 16:51:56 UTC 2010
Hi all,
I'm using a validation function which fires when publishing a particular custom post type:
add_action( 'publish_my_custom_post_type', 'validate_my_custom_post_type' );
function validate_my_custom_post_type() {
global $post;
if ( $some_form_value == '' ) {
$sendback = admin_url( 'post.php?post='.$post->ID.'&action=edit&message=200' );
wp_redirect( $sendback );
exit;
}
}
Although I'm able to filter the feedback messages to show a message when the condition is not met, prompting the user to take action..
add_filter( 'post_updated_messages', 'my_custom_post_type_feedback' );
function my_custom_post_type_feedback( $messages ) {
$messages['my_custom_post_type']['200'] = __( 'Some feedback message.', 'my_i18n_identifier' );
return $messages;
}
..I'm looking to show a $notice (error message, different color) in stead if a $message, but haven't found a way to do so.
Any pointers on how to accomplish this?
Cheers,
Barry
More information about the wp-hackers
mailing list