Add form title in Hidden field (Contact Form 7 WP Plugin)

Asked

Viewed 783 times

1

Good afternoon,

You can add the title of the Contact Form 7 plugin form in a Hidden field (Wordpress)

This is the shortcut used Plo plugin:

[contact-form-7 id="86" title="Titulo do Contacto"]

This is because I have a page with some options that open in a modal window, and in that window there is a form. I was able to change the page URL with an id when I opened it with java script, but the plugin "Contact Form 7 Dynamic Text Extension" will only find these parameters if it exists when opening the page and not if I change it after the page is loaded.

EDITION:

However I have already managed to access the form name with this script:

// add sortcut [hidden]
wpcf7_add_shortcode('hidden', 'wpcf7_sourceurl_shortcode_handler', true);

//função para ir buscar o titulo do formulário
function wpcf7_sourceurl_shortcode_handler() {

$name = "titulo_curso";
$form = wpcf7_get_current_contact_form(); // info sobre o formulário
echo '<pre>' . var_dump($form) . '</pre>';  
$html = '<input type="hidden" name="' . $name . '" value="' . $form->name() . '" />';

Return $html; }

However there is a problem because it will only fetch the title that is given in the backoffice, if I change the title in the shortcut [contact-form-7 id="86" title="Title of the Shortcut"] still sends me the title of backoffice.

Is there any way to fetch the title I entered in the shortcut?

Thank you

  • You can try https://wordpress.org/plugins/contact-form-7-modules/ ... Thanks to the documentation you can add Hidden Fields

  • Miguel thanks, but does not allow me to add the name of the form, the goal was to use the same form, for example with id 86, but change the title, so did not need to create a contact form for each item, or added the shortcut changed the title and so knew which item that contact referred to

  • The Contact Forms plugin uses the attribute title to fetch the form if the attribute id not provided. If attribute id is provided and is a valid form, the attribute title is ignored.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.