Skip Navigation

[Resolved] Passing Default Value to Taxonomy – Throws error, but works

This support ticket is created 9 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 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by vinceA 8 years, 12 months ago.

Assigned support staff: Waqas.


I am using the following code to pre-check one of my taxonomy options when using the form to create a custom post type post. When I use this code, submitting the CRED form works, but I am shown the included error as a temporary page before being shown the confirm message. All the data is being passed correctly into the custom post type. You can submit the form above and see the same thing, throw a name and select an option from the dropdown and the form works.

[cred_generic_field field="event-type" type="hidden" class="" urlparam=""]
Warning: in_array() expects parameter 2 to be array, string given in /home/issmin/ on line 1646

Warning: in_array() expects parameter 2 to be array, string given in /home/issmin/ on line 1646

Warning: Invalid argument supplied for foreach() in /home/issmin/ on line 1650


Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Please notice that the generic fields that you add to the form are not part of the post, so CRED will not process them automatically. You are free to use generic fields for whatever your application requires. Your processing should go into PHP code and run on CRED hooks. You can read about CRED Hooks at

Generally, it looks like you need to handle your generic hidden field, at the event when your custom post is being saved.

Please let me know if I can help you with anything related.


Thanks! Using this code modified to my needs I was able to tackle this:

add_action('cred_save_data', 'my_custom_save_data_action', 10, 2);
function my_custom_save_data_action( $post_id, $form_data ){
    // if a specific form
    if ($form_data['id']==213){
        $tag = array( 5 ); // add the id of your tag 'Thanksgiving'.
        $taxonomy = 'custom_taxonomy'; // add the slug of the taxonomy.
        wp_set_post_terms( $post_id, $tag, $taxonomy );