0

Here is the full code:

http://codepad.org/BpqQ3Xm0

Line 113, I am sending $_POST["popust"] ; And I use it to compare value at the top -line 33. But if I want to echo it, print_r, var_dump, inside page - after get_header();, I am getting empty results. Even if i define some variable at the top, i cant call it inside page as its always empty. Anyway, I need this $_POSTto test validation, but struggling to get it working.

1 Answer 1

0

Were you ever able to sort this out? I'm having the same issue. Best I can tell, somewhere after the save_post fires the $_POST data for that post/form gets trashed.

fwiw, what I'm considering doing is doing my validation and then using a post_meta as a proxy for $_POST. In other words, if validation fails write my form data to some post_meta. And whenever I'm displaying that form, I always first check for "error data".

To me this feel dirty and "hacky" but I'm also pretty sure it would work. After all, what is $_POST but an array. I don't think I want to store the whole $_POST in a post_meta, just the stuff I need for that form. And after all, that's where the form data is going to end up anyway...in post_meta.

Actually, now that I think about it, it might just be a matter of storing the validation error msg in post_meta and making sure a post isn't published unless the post_meta for error is blank. In other words, ! errors == OK to publish. Errors == Don't allow publish.

Storing "bad data" is fine. WP seems to be handling the storing just fine :) The real issue is error msgs AND preventing posts with "bad data" from being published.

What do you think?

FYI - This approach does in fact work, at least for custom post types and simple-ish forms. (It might work for more robust things but I'm kinda in proof of concept mode.)

The only thing I have to resolve is that WP will display "Post Published" (at the top of the page in a yellow box) even though I've bumped the post_status back to draft when the validation method(s) hit something that doesn't pass.

I'm pretty sure there's a way to suppress that, but I haven't looked into it just yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.