Skip Navigation

[Resolved] cred_success_redirect + get the information of saved data

This support ticket is created 9 years, 1 month 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 amanV 9 years, 1 month ago.

Assigned support staff: Waqas.

Author
Posts
#237889

Hello,

I am trying to get the information of the saved data in the function for the hook "cred_success_redirect".
My function looks likes this:

[code]

add_filter('cred_success_redirect_131', 'custom_redirect_for_form_with_id_131',10,3);
function custom_redirect_for_form_with_id_131($url, $post_id, $form_data)
{

if ($form_data['id']==131)
exit(var_dump($form_data));
}
[/code]

But the only thing I see in the output is:

[code]
array (size=3)
'id' => int 131
'post_type' => string 'customers' (length=9)
'form_type' => string 'new' (length=3)
[/code]

I would like to be able to get/fetch what information is saved.

Please can you help me with this?

regards

#237948

Waqas
Supporter

Languages: English (English )

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

You are right $form_data is an associative array of data about current form (like id, post_type and form_type). You may need to query the saved data based on the $post_id, for example:

get_post($post_id);

Dump of $_POST may also be helpful to find what's available at hand.

print_r($_POST)

Following sample code may also help you understand:

add_filter('cred_success_redirect_131', 'custom_redirect_for_form_with_id_131',10,3);
function custom_redirect_for_form_with_id_131($url, $post_id, $form_data) {
	// See what we've at hand
	/*print_r($form_data);
	print_r($_POST);
	die();*/

	if ($form_data['id']==131) {
		// Fetch what was saved
		$saved_data = get_post($post_id);

		// Process $saved_data
		// i.e. prepare an email, create another post or update existing post
		$blogpost = array(
			'post_title' => wp_strip_all_tags("New book is now available: {$saved_data->post_title}"),
			'post_content' => "A new book has been added, <a href=\"".get_permalink($post_id)."\">{$saved_data->post_title}</a>.",
			'post_status' => 'publish',
			'post_author' => 1,
			'post_category' => array(1)
		);
		
		wp_insert_post( $blogpost );
		
		// Or redirect to any desired location
		return '<em><u>hidden link</u></em>';
	}
	
	return $url;
}

Please let me know if you are satisfied with my answer and if I can help you with any other related question.

#238080

Thank you very much for a prompt reply.