Contact Form 7 if on the Specific Page.. Do something.
-
I have a custom code implemented on submit function, where after the user put their email and select dropdown menu and submit.
they will recieve an email corresponding to what they choose on the dropdown.My problem is I have only used 1 form on 5 different Page, and I would like to add additional code to determine in what page is the form submitted before taking action.
Here’s my code that determine based on user selection.
add_action( 'wpcf7_before_send_mail', 'different_autoresponder_message' ); function different_autoresponder_message( $cf7 ) { //check if this is the right form if ($cf7->id==635){ //Do Something Here //Spacing for additional Messages if ($cf7->mail['use_html']==true) $nl="<br/>"; else $nl="\n"; //Set Message Depending on User Selection if($_POST['menu-689'] == '1 Day Course') { $message=$nl.$nl.'1 Day Course'.$nl; $message.='Thank For your Download..'.$nl; } else { $message=$nl.$nl.'User Dont want it'.$nl; $message.='No more Download..'.$nl; } $cf7->mail_2['body'].=$message; } }
Its working properly,
However, since the form is used more than 3 times.I’d also like to changed the message based on what Page is the form.
so In short, I have two action to determine before form submission. first is based on the user Selection on the form dropdown(which I already achieved). and second is in what page is the form.
I’ve tried adding if is_page statement on the code but its not working,
Something like this.
//Set Message Depending on User Selection if (is_page(1455)) { if($_POST['menu-689'] == '1 Day Course') { $message=$nl.$nl.'1 Day Course'.$nl; $message.='Thank For your Download..'.$nl; } else { $message=$nl.$nl.'User Dont want it'.$nl; $message.='No more Download..'.$nl; } } else { // Do Something.... }
Can anybody help?
Much Appreciated..
Regards,
Kenn
- The topic ‘Contact Form 7 if on the Specific Page.. Do something.’ is closed to new replies.