WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Performing an action when a specific form is used? (2 posts)

  1. gsilver
    Member
    Posted 3 years ago #

    Let's say I have 3 forms, form1, form2, and form3.

    I also have the following code:

    add_action( 'wpcf7_before_send_mail', 'do_something' );
    
    function do_something($cf7)
    {
      /* Does something */
    }

    What variable would I need to check to ensure I'm working with form1, and not the others.

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 3 years ago #

    This should work.

    function do_something( $cf7 )
    {
    	if ( 1 == $cf7->id ) {
    		/* Does something */
    	}
    }

    Or if the "form1" is title,

    function do_something( $cf7 )
    {
    	if ( 'form1' == $cf7->title ) {
    		/* Does something */
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic