Home › Forums › Front-end Issues › Make fields required only on front-end form? › Reply To: Make fields required only on front-end form?
Actually scratch that, acf_load_field
is too powerful and actually prevents you from setting the fields to be required anywhere.
My solution was to set the fields to be NOT required and then make them required only on the frontend form, like so:
add_filter('acf/load_field/key=field_XYZ', 'custom_field_required_fields');
function custom_field_required_fields($field) {
if (!is_admin()) {
$field['required'] = true;
}
return $field;
}
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.