Support » Plugin: Contact Form 7 » [Plugin: Contact Form 7] Performing an action when a specific form is used?

  • 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.

Viewing 1 replies (of 1 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    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 */
    	}
    }
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Contact Form 7] Performing an action when a specific form is used?’ is closed to new replies.