WordPress.org

Forums

Promotion Slider
Passing parameters within a template (8 posts)

  1. andyscraven
    Member
    Posted 1 year ago #

    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

  2. Micah Wood
    Member
    Plugin Author

    Posted 1 year ago #

    Andy,

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

  3. andyscraven
    Member
    Posted 1 year ago #

    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.

    http://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

  4. Micah Wood
    Member
    Plugin Author

    Posted 1 year ago #

    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 http://mysite.com/my-form you would just change the link to something like this http://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.

  5. andyscraven
    Member
    Posted 1 year ago #

    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

  6. Micah Wood
    Member
    Plugin Author

    Posted 1 year ago #

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

  7. andyscraven
    Member
    Posted 1 year ago #

    Hi

    Yeah it is, so Hoorah and thank you.

    Do you have a developer license?

    Andy

  8. Micah Wood
    Member
    Plugin Author

    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic