advancedforms / advanced-forms

WordPress plugin to create forms using Advanced Custom Fields
75 stars 14 forks source link

Ability to exclude fields on a per form render #7

Closed daviddarke closed 7 years ago

daviddarke commented 7 years ago

So... I've actually used this twice (on two separate sites) this week. I have a signup form that includes:

These fields are saved in an ACF field group that is then assigned to a user 'signup form' and a 'profile edit form'.

When a user signs up and the form gets processed, I create a new user and allocate the crucial data (First Name, Last Name and Email) to the actual user account, and the other fields just to standard custom field on the user.

Once the user is signed up, there is an edit form on their profile. I do not want them to edit their email address assigned to their account. So I can pass the field reference into the 'exclude_fields' arg and that field is skipped from rendering and validation on just the edit form. Like:

$args = array(
    'exclude_fields'          => array('field_58deaec4485d3')           
);

advanced_form( 'form_58deb014ec477', $args );

Give it a spin and let me know your thoughts :)

fabianlindfors commented 7 years ago

This is a brilliant idea, David! Thanks for contributing.

Will merge and add it to the documentation a little later. :)

fabianlindfors commented 7 years ago

I also added the option to exclude fields based on their names: 7d8566712e91ab2d4724905af3e66d609e8f6569

daviddarke commented 7 years ago

👍