I'm a novice in wordpress trying to work with Contact Form 7 plugin. I'd like a specific cf7 form to be submitted to external URL. I searched and found these references and utilized them.
https://babelscribe.nz/wordpress-3/contact-form-7-change-action-url/ https://wordpress.stackexchange.com/questions/290373/contact-form-7-custom-post-action how to change form action url for contact form 7?
I had put this in my wp-config.
define('WP_DEBUG', false);
Then, I put this in my functions.php
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url() {
return 'https://myurl.com/index.php';
}
With this, I was able to submit all of contact form 7 to myurl.
However, now I wanted to change this and submit forms to URL depending on form ID. So, I used this to submite a contact form with ID=78 to myurl.com
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url(){
global $wpcf7_contact_form;
if ($wpcf7_contact_form->id === 78){
return 'http://myurl.com/index.php';
}
}
But, this did not work. I'm not able to understand why this is happening when I'm following the exact solutions reported by above referred references.
Could you please help me?
Thanks in advance,