I need to know what I’m doing step-by-step with:
1. Advanced Forms
2. Form created
3. ACF
4. Page templates (php)
Hi!
For your use case you probably won’t even have to write any PHP code, I’ll give you step-by-step instructions.
The first step is to create your form. You can do this by going to “Add new” under “Forms” in the WordPress admin. Give your form a descriptive name (such as “Appointment request”) and then publish it. We’ll come back later to configure the form further but the defaults are good for now.
The second step is adding fields to our form and this is done through the regular ACF interface. Go to “Custom fields”, create a new field group and then under “Location” select “Form” and the form we just created. Now you can add all the fields you want to include in your form!
Next up is configuring your form so that it saves data/sends emails or whatever you want it to do. Go back to “Forms” and edit the one you just created. If you want to automatically save all submissions to WordPress go to “Entries” and check “Create entries?”. If you want any email notifications sent upon submission you can configure those under “Notifications”. I’d also recommend going to “Display” and setting up a success message which will be displayed after submission.
The last step is displaying your form which can be done in two ways, either with a simple shortcode or a PHP snippet. Before leaving the form edit page go to the top and make note of your unique form key which is shown beneath the title input. We’ll use this key to specify which form to display where.
If you want to show you form on a specific page or post using a shortcode is the most convenient and also doesn’t require any custom PHP code. Go edit the page you want to display your form on and insert this shortcode: [advanced_form form="FORM_KEY"] where FORM_KEY should be replaced by the unique form key you took note of earlier. If you save the page and navigate to it your form should now be shown with all the fields you added earlier, ready for use!
If you want to display your form in a location which doesn’t fit in with the rest of your content the shortcode probably won’t work well. Then I would instead recommend adding a tiny PHP snippet to your page template or similar file. The snippet looks like this: <?php advanced_form( 'FORM_KEY' ); ?> where FORM_KEY is your forms unique key.
I hope this helped and if not feel free to specify further what you need help with. These steps are also detailed in the documentation: https://advancedforms.github.io
Have a good one!