If you’re using Fluent Forms and need to dynamically populate form fields based on context (like a specific service page or user action), this snippet lets you pass values directly through the form’s shortcode using custom attributes. Simply add prefill_ before your field name and provide the value you want to pre-populate.
This is especially useful when you’re embedding the same form across multiple pages but want to customize the default values based on context, without creating separate forms for each scenario.
Example Use Case
Let’s say you have a “Services” form and you want to pre-select a service based on which page the user is viewing. Your shortcode would look like this:
[fluentform id="2" prefill_service="Web Design"]
In this example, since your form has a field named service , it will automatically be populated with “Web Design” when the form loads. You can add as many prefill_ attributes as you need, one for each field you want to populate.