• Resolved andyscraven

    (@andyscraven)


    Hi

    I have embedded the shortcode in to my template file but I want to preload some of the data.

    The customer will be enquiring about a specific event and I would rather preload a text field with the event data so they don’t have to type it in.

    Is this possible?

    Thank you

    Andy

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Micah Wood

    (@woodent)

    Andy,

    I am not entirely sure what you are trying to do… perhaps you could give a little more background?

    Thread Starter andyscraven

    (@andyscraven)

    Hi

    I put a really bad subject line up here but I am using Contact-Form-7 and I have embedded the Shortcode in a php template.

    In contact form 7 you have a number of fields the user can fill in but I wanted one of the fields already filled in with the event they are actually enquiring about yo save the user having to do it themselves.

    https://www.murdermostfoul.dreamhosters.com/events/event/a-grease-weekend/

    If you hit the Enquire button you will see one of the fields in “Event”, given we are already on the event page it would make sense to have it already filled in.

    Thanks

    Andy

    Plugin Author Micah Wood

    (@woodent)

    From personal experience I am a bit biased against Contact Form 7, but I think Gravity Forms would be the easy solution.

    You could link your enquire buttons to the form with the current event (post) id passed as a variable in the URL. So instead of linking like this https://mysite.com/my-form you would just change the link to something like this https://mysite.com/my-form?event=210.

    Next, you just create a function in your active theme’s functions.php file that hooks into Gravity Forms and passes the value from the URL to Gravity Forms.

    Finally, anytime you want to use that URL parameter as a value in your form, just check the ‘Dynamically populate this field’ check box in Gravity Forms and enter the name of the variable you setup.

    Gravity Forms is really slick and I don’t setup a site without it. It is about 1,000 times easier to work with than Contact Form 7 and is extremely flexible when it comes to more advanced configurations like you are looking for.

    Thread Starter andyscraven

    (@andyscraven)

    Hi

    That sounds great.

    Can I simply embed a <?php gravity_form(…) ?> and pass a field through already populated with $EM_Event->name from the Event Manager plugin?

    Andy

    Plugin Author Micah Wood

    (@woodent)

    Basically, if the value is globally accessible in the present state, then the form can use it to prepopulate.

    Thread Starter andyscraven

    (@andyscraven)

    Hi

    Yeah it is, so Hoorah and thank you.

    Do you have a developer license?

    Andy

    Plugin Author Micah Wood

    (@woodent)

    I do. A developer’s license is the only way to go if you work with multiple sites!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Passing parameters within a template’ is closed to new replies.