Skip Navigation

[Resolved] Types fields not updating

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.

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

Problem: I am using cred_save_data to perform some actions after form submission, but the update_post_meta calls do not seem to be working as expected.

Solution: Check your code syntax, compare $_POST keys, and debug using the server logs.

This support ticket is created 6 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by MikeT458 6 years, 2 months ago.

Assisted by: Christian Cox.


I am trying to: create a SUPERVISOR and a TEAM MEMBER record when a new SUPERVISOR is added via CRED

add_action('cred_save_data_277', 'save_data_for_form_with_id_277',10,2);
function save_data_for_form_with_id_277($post_id, $form_data)
		// if supervisor CPT does not exit, create it
		$first_name = $_POST['first_name'];
		$last_name = $_POST['last_name'];
		$user_id = $post_id;
		$facility_id = $_POST['facility'];
		$department_id = $_POST['department'];
		$user_name = $_POST['user_login'];
		$try_title = $last_name.", ".$first_name;
		if(!sbf_post_exists($try_title, 'supervisor')){
//this works
			$supervisor_post_id = wp_insert_post(array(
				'post_type' => 'supervisor',
				'post_title' => $try_title,
				'post_status' => 'publish'

/* this doesn't - the fields are defined as SELECT in the CRED USER FORM storing the post_id of a facility and a department
in the supervisor custom fields super-visor facility and supervisor-depart as defined as post reference fields. */

		update_post_meta($supervisor_post_id,  'wpcf-user-id', "$user_id");	
		update_post_meta($supervisor_post_id,  'wpcf-supervisor-facility', "$facility_id");	
		update_post_meta($supervisor_post_id,  'wpcf-supervisor-department', "$department_id");	

		// same routine for team member as far as it goes
		if(!sbf_post_exists($try_title, 'team-members')){

//this works			
			$team_post_id = wp_insert_post(array(
				'post_type' => 'team-members',
				'post_title' => $try_title,
				'post_status' => 'publish'

/*this doesn't - these 3 fields are defined as check boxes. I can see the data in phpmyadmin but the fields are not checked in the admin display*/

		update_post_meta($team_post_id,  'wpcf-is-full-time', "1");	
		update_post_meta($team_post_id,  'wpcf-is-management', "1");	
		update_post_meta($team_post_id,  'wpcf-is-active',"1");	


Thanks for any insights.


Try removing the quotation marks around the 3rd parameter of the update_post_meta calls:

        update_post_meta($supervisor_post_id,  'wpcf-user-id', $user_id); 
        update_post_meta($supervisor_post_id,  'wpcf-supervisor-facility', $facility_id); 
        update_post_meta($supervisor_post_id,  'wpcf-supervisor-department', $department_id); 
        update_post_meta($team_post_id,  'wpcf-is-full-time', 1); 
        update_post_meta($team_post_id,  'wpcf-is-management', 1);    
        update_post_meta($team_post_id,  'wpcf-is-active',1); 

If this doesn't seem to work as expected, try writing out these values to the server log to debug:

        update_post_meta($supervisor_post_id,  'wpcf-user-id', $user_id); 
        update_post_meta($supervisor_post_id,  'wpcf-supervisor-facility', $facility_id); 
        update_post_meta($supervisor_post_id,  'wpcf-supervisor-department', $department_id); 
        error_log('supervisor: ' . $supervisor_post_id . ', user: ' . $user_id . ', facility: ' . $facility_id . ', dept: ' . $department_id);

If you're not familiar with server logs, I can show you how to activate them temporarily. Go in your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:

define('WP_DEBUG', true);

Then add these lines, just before it says 'stop editing here':

ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

Submit the CRED form again and a file should be generated in the root directory of your site called error_log.txt. Please send its contents along with your next reply.



Removing the quotes took care of the numerical "is_" fields, but not the facility and department. I turned on the server logs as you suggested and saw the errors for undefined index for the two fields in question. I var_dump'ed $_POST and discovered the field names in the CRED form did not match what was in post. I prefixed both fields with "wpcf-" and all is well. Thank you for your assistance!

The forum ‘Types Community Support’ is closed to new topics and replies.

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