Skip Navigation

[Resolved] Add filter to cred form

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

Problem:

Add multiple form IDs to custom codes.

Solution:

You can use PHP function in_array() to check more form ID as an array, for example:

https://toolset.com/forums/topic/add-filter-to-cred-form/#post-1131547

Relevant Documentation:

http://php.net/in_array

This support ticket is created 5 years, 6 months 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)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1130668

Hi,

I've t used the the followuin code to add a filter as you sagget me in a previeus ticket.

The code is:

if($cart_item['cred_meta']['cred_form_id'] != 24662 || !isset($cart_item['cred_meta']['cred_post_id']) ) || return $name;
....

I've to add the same filter to another form. How I've to change the code? I tryed wuth this, but is does not works

if($cart_item['cred_meta']['cred_form_id'] != 24662 || $cart_item['cred_meta']['cred_form_id'] != 25474 || !isset($cart_item['cred_meta']['cred_post_id']) ) || return $name;
....
#1131547

Hi,

You can use PHP function in_array() to check more form ID as an array, for example:

if( in_array($cart_item['cred_meta']['cred_form_id'], array(24662, 25474))
|| !isset($cart_item['cred_meta']['cred_post_id']) ) || return $name;

More help:
hidden link
Checks if a value exists in an array

#1132277

My issue is resolved now. Thank you!

#1132451

You are welcome

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