Support » Plugin: Contact Form 7 » [Plugin: Contact Form 7] add HTML to begining of form

  • What would be the proper way using hooks to insert some HTML (depending if user is logged in) right before the form code?

    {insert my html here}
    <div class=”wpcf7″ id=”wpcf7-f1-p2-o1″><form action=…

    And where should I check if user is logged in without modifying plugin code?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Not sure if it is the proper way but it works fine for me.

    On the form-page where I have the CF7 shortcode I do something like that with PHP Execution plugin.

    It is there where you can also check the user login and so on.
    You can then conditionally include a form with PHP rather than HTML:

    echo do_shortcode( ‘[contact-form x “My form”]’ );

    Enjoy, Piet

    Without plugins, you could do this:

    1. Create a page template with the HTML you want to appear before or after the form (you can copy your page.php as a start. You can prefix that custom html with a call for if (is_user_logged_in()): so it only appears to logged in users. Make sure the the_content(); call happens where you want the form to appear.
    2. Edit the page where you have the form. Make sure the proper shortcode is in the content. Change the template to the template you just created.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Contact Form 7] add HTML to begining of form’ is closed to new replies.