[Resolved] Add filter to cred form

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.

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

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 1 month, 3 weeks ago.

Assigned support staff: 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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

You are welcome