Would anyone know how to assign form dynamically via ACF?
I have a "webinar" CPT and would like to define the custom field that would pull the FluentForm shortcode value dynamically. Would anyone know how to go about that?
Here is he example webinar:
https://balanceinhr.com/webinar/health-in-workplace/
Thanks in advance!
Which part should be dynamic? ACF doesnβt make it dynamic. It just adds a field.
Andre DausΒ the fluent form shortcode.
Basically, I want to create a new form for every webinar so that I can sent the entries to appropriate segment and automate marketing. This page as is now, has the particular form added via shortcode, but how would I go about adding another form to the new webinar without modifying the CPT template?
Drag IvkoΒ thatβs not how dynamic data works. Usually, you add the custom data in custom fields to the CPT post. You should use only one form per CPT, otherwise it gets messy quickly. Then you create a template that uses the custom field data to render the page dynamically. With Fluent Forms you have different options depending on your particular use-case:
- Use Query Parameters (easiest): open the CPT with the custom fields as query parameters and pull them into the form fields with FluentForms default data, see here: https://wpmanageninja.com/docs/fluent-form/miscellaneous/default-value-in-wp-fluent-forms/
- Create your own short code and fill in the custom fields data directly in the short code without any ugly query params, see here: https://snippetclub.com/how-to-dynamically-pre-fill-fluent-forms-fields-using-custom-shortcode-attributes/
- Create a filter to fill all necessary data via PHP (most reliable, but hardest): Fluentforms provides numerous filter hooks. You might want to look for this: https://fluentforms.com/docs/fluenform_rendering_field_data_input_key/
Bonus: If you really want to create a form for each CPT (not recommended!), you can add a custom field for the forms ID and then add it to your template with a placeholder in the basic shortcode [fluentform id={custom_form_field}] (depending on your templating).
Not every option will work depending on your theme. I use Bricks Builder with BricksExtras, so Iβd go for option #3 (because it does not work with shortcodes). In any other case go with option #1 or #2.
This is so helpful Andre, let me look into the links you shared. Thanks so much!