I\'m adding validation so if a post is in a particular category, it needs certain Custom Fields to be set.
This should be easy hooking wp_insert_post_data
You can simply do like WordPress do : using transients like this :
function set_post_pending($data, $postarr) {
// If it's not valid...
$error = "You are missing some Custom Fields.";
set_transient( get_current_user_id().'missingfield', $error );
$data['post_status'] = 'pending';
return $data;
}
add_filter('wp_insert_post_data', 'set_post_pending',1,2);
function show_admin_notice() {
if($out = get_transient( get_current_user_id().'missingfield' ) ) {
delete_transient( get_current_user_id().'missingfield' );
echo "$out
";
}
// return false; // nothing to return here
}
add_action('admin_notices', "session_admin_notice");
ps : avoid $_SESSION in WordPress, thx