-1

I've been digging a little into Contact Form 7 source code without success, but I was wondering if, like in Advanced Custom Fields, it's possible to hardcode a complete form (fields, recipients and required rules) in a theme using the WordPress API.

I don't expect a good straightforward way, but at least a way that I could deploy my websites without having to depend on DB-specific inputs.

Also, I don't refer to this solution, that uses a do_shortcode and still needs us to create the forms.

Has anyone done something similar with Contact Form 7?

closed as off-topic by fuxia Apr 21 '14 at 21:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • What do you need exactly that WPCF7 can't provide? I've created some custom forms, but all in the context of WPCF7 and I haven't felt the need to actually code the form itself. – Howdy_McGee Apr 21 '14 at 19:29
  • I would like to use WPCF7 functionalities, verifications and e-mails without having to create forms in the admin interface, as these forms are meant to be deployed with the rest of the website. So, in this perspective, better to hardcode them like we can do in ACF. – vmassuchetto Apr 22 '14 at 10:33
  • @toscho, didn't quite understand why the question is off-topic. I see it as WordPress specific as it is a theme development idea around the WordPress API, and Sormano gave a good clue of what's possible. – vmassuchetto Apr 22 '14 at 10:36
  • Well, just saw this: meta.wordpress.stackexchange.com/questions/3844/… :) – vmassuchetto Apr 22 '14 at 10:49
  • 1
    @vmassuchetto The solution is specific to that plugin, not to WordPress. – fuxia Apr 22 '14 at 11:06
1

I've looked for this some time ago.

Best thing you can do is change the default contact form.

Filter you can use: wpcf7_default_template

Info can be found in contact-form-7/includes/functions.php file line 63

The filtered variable is:

$template =
    '<p>' . __( 'Your Name', 'contact-form-7' ) . ' ' . __( '(required)', 'contact-form-7' ) . '<br />' . "\n"
    . '    [text* your-name] </p>' . "\n\n"
    . '<p>' . __( 'Your Email', 'contact-form-7' ) . ' ' . __( '(required)', 'contact-form-7' ) . '<br />' . "\n"
    . '    [email* your-email] </p>' . "\n\n"
    . '<p>' . __( 'Subject', 'contact-form-7' ) . '<br />' . "\n"
    . '    [text your-subject] </p>' . "\n\n"
    . '<p>' . __( 'Your Message', 'contact-form-7' ) . '<br />' . "\n"
    . '    [textarea your-message] </p>' . "\n\n"
    . '<p>[submit "' . __( 'Send', 'contact-form-7' ) . '"]</p>';

Hope this helps.

Not the answer you're looking for? Browse other questions tagged or ask your own question.