WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7 PHP Invocation Code? (17 posts)

  1. Greg Rickaby
    Member
    Posted 5 years ago #

    Hello. I am using Thesis, and would like to know if there is PHP invocation code so I can use Hooks rather than a text widget.

    Example: instead of this: [contact-form 1 "Contact form 1"] is there: <?php contact_form(1) ?> ???

  2. lemodesign
    Member
    Posted 5 years ago #

    I would love to find this out too so i can put this into a layout rather then using de text editor in wp.

  3. devicbojan
    Member
    Posted 5 years ago #

    You have it here.

  4. Matrakkas
    Member
    Posted 4 years ago #

    Hello!

    I tried the code you highlighted in your website Devic, but it is not working for me.

    I get the next error:

    Fatal error: Call to a member function form_scan_shortcode() on a non-object in /.../public_html/wp-content/plugins/contact-form-7/modules/file.php on line 63

    Any idea?

    Thanks in advanced

  5. devicbojan
    Member
    Posted 4 years ago #

    Sorry, I have tested this code only localy on XAMPP and it worked. You only need to add:
    global $wpcf7_contact_form;
    as first line of php code, I have updated post on my website.

  6. semrocc
    Member
    Posted 4 years ago #

    Unfortunately I have not been able to get this code working...just produces page errors in ie and stalls out when trying to submit the form.

  7. Adam Harley
    Member
    Posted 4 years ago #

    Just use do_sortcode() ?

  8. semrocc
    Member
    Posted 4 years ago #

    Thanks very much...that worked great :)

  9. devicbojan
    Member
    Posted 4 years ago #

    The code I've posted works on my site and in XAMPP just copy paste it. The do_shortcode() works to, I didn't know about do_shortcode() function. Thank you Kawauso.

  10. semrocc
    Member
    Posted 4 years ago #

    I'm not sure why I couldn't get your invocation code to work, but the do_shortcode() function seems to be something that probably won't be affected by updates and newer versions, so probably a better option.

  11. Kai2810
    Member
    Posted 4 years ago #

    Hi guys, I think I'm having the same problem, trying to embed Contact Form 7 into my template php file.

    semrocc, do you mind showing how you use the do_shortcode() function?

    I'm a noob in php...

  12. devicbojan
    Member
    Posted 4 years ago #

    Just change the number and name of the contact form

    <?php echo do_shortcode("[contact-form 1 'Contact form 1']"); ?>

  13. semrocc
    Member
    Posted 4 years ago #

    Yes...exactly as above...thanks

  14. Designs Genius
    Member
    Posted 4 years ago #

    A useful "Invocation code" ! Thanx for the "do_shortcode" I needed !

  15. dplatt
    Member
    Posted 4 years ago #

    Thank you semrocc and devicbojan the do shortcode is what I needed too!

  16. alanlongmore
    Member
    Posted 4 years ago #

    Thank you for this

  17. Kai2810
    Member
    Posted 4 years ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic