Skip Navigation

[Resolved] I am still confused the form IDs in PHP codes

This thread is resolved. Here is a description of the problem and solution.

Problem:

How to use apply same function to multiple post forms IDs using action hook cred_save_data?

Solution:

You try with PHP function in_array, for example:

$forms = array(1123, 4647 );
 
if ( in_array($form_data['id'], $forms) ){
...
}

Relevant Documentation:

https://www.php.net/manual/en/function.in-array.php

This support ticket is created 3 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by ianG-5 3 years ago.

Assisted by: Luo Yang.

Author
Posts
#2030499
$form_data['id'] == 1123 || 4647

Should be

$form_data['id'] == 1123 || form_data['id'] ==4647

still find it odd and concerning that php passed the condition.

#2030503

Hello,

I suggest you try with PHP function in array, for example:

$forms = array(1123, 4647 );

if ( in_array($form_data['id'], $forms) ){
...
}

More help:
hidden link

#2030811

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.