I don’t know why you need to suspend validation on the frontend, but you could just disable validation on those fields you don’t need it on…
Thread Starter
polr
(@polr)
I know it seems illogical but it’s what’s required. They need to be inputting information on two different forms (with only about 50% similar fields) that needs to be validated (there’s been a lot of customisation) then on the edit page it pulls over all fields from all form fields so some of the fields are required at the edit when they don’t apply.
It was either that or I needed to be able to create two different/tailored pdb_single pages but I couldn’t see how to do that (well, I couldn’t see how to specify different pdb_single pages were used per form as it’s set once in the admin settings) so this would be a rougher alternative that would allow edits to go through.
From the code I supplied to begin with, can you see if there is any obvious reason why this wouldn’t work?
Thanks
Well, at the point where this test is taking place, the post object has not been instantiated. So, WP doesn’t know which page it is yet. Without digging deeper, I’d say you need to test the server variable against the page name:
$_SERVER['REQUEST_URI'] != "/page-name/"
Where ‘page-name’ is the slug of your page. You could also use a “strpos” test if the end slash isn’t always there.
Thread Starter
polr
(@polr)
Hi,
Thanks for that, just in case anyone should ever need it (and yes, I’m not sure why either) my solution was to do this in participants-database.php at line 1808:
$post_id = (206);
$post = get_post($post_id);
$slug = $post->post_name;
if (!is_object(self::$validation_errors) and ! is_admin() and !strpos($_SERVER[‘REQUEST_URI’], $slug))
self::$validation_errors = new FormValidation();