$_POST data cannot be retrieved/is empty?
-
Hello, I am encountering a problem I can’t seem to solve…
I created a custom post type for an agenda, where a band can enter their shows. It is important that the date of the show is entered in the following format: dd-mm-yyyy. I check the date with preg_match, and if the date is entered in any other format, the post isn’t saved. I use this code for this in the function that is hooked to the save_post hook:
if ( !preg_match( "/\d\d-\d\d-\d\d\d\d/", $_POST[ 'topsecreet_agenda_datumoptreden' ] ) ){ return $post_id; }
However, if I use this code there is still a default wordpress message that says that the post is saved (though it is not), and I’d also like to add a custom message to the formfield itself, providing additional information tp the user.
The problem is that I fail to find a way to get the information I need for this into the function that creates the metafields. If I use ( isset ( $_POST[ ‘topsecreet_agenda_datumoptreden’ ] ) ) it keeps returning false. So I assume the $_POST data gets lost somewhere between the submit button and the reload of the page… Is there a way to pass it on so I can re-use it for display in the meta-boxes?
- The topic ‘$_POST data cannot be retrieved/is empty?’ is closed to new replies.