PHP syntax help for checking multiple IDS in an array -


i using contact form 7 in wordpress , had create custom hook form action url. have working if want check if particular forms "id" exist, , if send url. code looks this:

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');  function wpcf7_custom_form_action_url($url) {     global $wpcf7_contact_form;      if ($wpcf7_contact_form->id === 333)     {         return 'http://mydomain.com/leads/';     }     else     {         return $url;     } } 

however, have 4 forms want check see if of them exist send same url above (where domain url). if try adding multiple ids breaks. have tried:

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');  function wpcf7_custom_form_action_url($url) {     global $wpcf7_contact_form;      if ($wpcf7_contact_form->id === 333 || 334 || 335 || 336)     {         return 'http://mydomain.com//leads/';     }     else     {         return $url;     } } 

the code above seems not work.

i have tried check array this:

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');  function wpcf7_custom_form_action_url($url) {     global $wpcf7_contact_form;      if( !in_array($wpcf7_contact_form->id,array(660, 684, 685, 686)))     {         return 'http://mydomain.com/leads/';     }     else     {         return $url;     } } 

again, appears not correct. can see incorrect above. can't seem working.

you wish check forms e.g. ids (660, 684, 685, 686) right?

if case, have inverted in_array statement (! in_array)

change:

if( !in_array($wpcf7_contact_form->id,array(660, 684, 685, 686))) 

into

if(in_array($wpcf7_contact_form->id,array(660, 684, 685, 686))) 

at least, in_array best way check multiple values. should kept in final code!


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -