Home › Forums › Front-end Issues › Front-end acf_form: field validation returning a WP error page › Reply To: Front-end acf_form: field validation returning a WP error page
I’m not sure that’s the case: the function validate_save_post
in /core/validation.php
will wp_die()
with the validation message if the $show_errors
parameter is set to true, which is exactly what I’m getting above.
Doing a manual stack trace, it looks like it’s being called from save_user()
in /forms/user.php
, wherein it checks if acf_validate_save_post(true)
returns true, then save the user info. That parameter is $show_errors
, and is hard-set.
For the sake of a sanity check, I enabled WP_DEBUG and all I got were a couple of notices about an undefined index in my functions file. I amended those and still got the same result, but having looked at the code, it looks like this is how it’s supposed to behave?
Just to be clear: I’m using acf_form()
on the front end to update user details. There are a couple of forms on the same page, and they all work – whenever I submit a form, I get the little spinner, then the page refreshes with the query_vars
specified in my acf_form()
as $_GET
arguments. It’s just that when one of the required fields is left blank, I end up with this ugly wp_die()
screen instead of either some ajax response or an in-form error message.
For reference, here’s my code:
$userObject = wp_get_current_user();
$userID = $userObject->ID;
$profileOptions = array(
'post_id' => 'user_' . $userID,
'id' => 'profile-form',
'field_groups' => array('vnm_profile__acf_group_user_profile'),
'form' => false,
'return' => add_query_arg(array('section-updated' => 'profile', 'updated' => 'true'), get_permalink()),
'updated_message' => __('Profile information updated!', 'my-theme'),
'submit_value' => __('Update Profile', 'my-theme'),
);
acf_form($profileOptions);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.