Contact Form 7
add HTML to begining of form (3 posts)

  1. menciuspk
    Posted 4 years ago #

    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?


  2. Karesansui
    Posted 4 years ago #

    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

  3. cjlarose
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic