• Resolved Xonox

    (@xonox)


    Hi,

    I’m trying to add a specific action to a form but I can’t find a way to single it out because all the methods I’ve been searching for, simply fail.

    Here’s the code I’m using:

    function newsletter_subscription_action($url) {
    	global $wpcf7_contact_form;
    	if($wpcf7_contact_form->ID === 'myformid') {
    		return('myaction');
    	}
    	else {
    		return $url;
    	}
    }
    add_filter('wpcf7_form_action_url', 'newsletter_subscription_action');

    It seems that $wpcf7_contact_form doesn’t exist. Can someone give me a hand. I have no idea what variable I should use to get the form ID.

    Thank you,

    https://www.ads-software.com/plugins/contact-form-7/

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

    (@takayukister)

    Change it to this:

    $current = WPCF7_ContactForm::get_current();
    
    if ( $current->ID === 'myformid' ) {
    	...

    Thread Starter Xonox

    (@xonox)

    Mr. Takayuki Miyoshi,

    Your tip made it work! Thank you very much for the quick resolution and for a great plugin.

    I just sent you a donation to keep you motivated! ??

    Regards!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can′t single out a specific form through ID’ is closed to new replies.