Skip Navigation

[Resolved] Cred submission overwriting data

This support ticket is created 7 years, 2 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
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 1 reply, has 2 voices.

Last updated by Christian Cox 7 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#569776

When two people open the form, they get the same _cred_cred_prefix_post_id, so when the form is submitted the content of the post of the first submitted form get replaced by the content of the second.

We try to use the cred_before_save_data hook to replace the id in the form data without success.

This is the hook code :

add_action('cred_before_save_data_288', 'valide_cred_cred_prefix_post_id',15,1);
function valide_cred_cred_prefix_post_id($form_data){

		if (isset($_REQUEST['_cred_cred_prefix_post_id']) || isset($form_data['_cred_cred_prefix_post_id'])){
				$goodid=good_id($_REQUEST['_cred_cred_prefix_post_id']);
				$_POST['_cred_cred_prefix_post_id'] = $goodid;
				$_REQUEST['_cred_cred_prefix_post_id'] = $goodid;
				$form_data['_cred_cred_prefix_post_id'] = $goodid;	
		}

	return $form_data;
}

function good_id($id){
		while (get_post_status($id)) {
			$id++;
		}
		return $id;
	}

#569824

Hi, I see that your plugins are quite out of date, as well as your WordPress installation. Quite a few updates have been made to CRED, including some bug fixes in the new post creation sequence. My first recommendation is to update WordPress and all Toolset plugins and retest. Make a full backup of your site files and database before you try to update.

https://toolset.com/download/toolset-cred/#changelog