Skip Navigation

[Resolved] cred save data hook form data

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 5 replies, has 1 voice.

Last updated by Minesh 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2787234

I am trying to: get form dat

Link to a page where the issue can be seen:

I expected to see: $form_data
in the hook

Instead, I got: only post id

#2787282

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

There is not much information you shared. Can you please tell me what exactly you want and share brief description about your issue.

#2787283

Hi there.
i am trying to hook on: add_action('cred_save_data', [__CLASS__, "save_data"]);
when save_data is called it gets passed only one parameter instead of 2. I get only the post id. No form data is there.

#2787424

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I'm not sure where and at what contaxt you are usging the code you shared.

Normally, the cred_save_data action should be used as you can see with the following oficial Doc:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

For example:

////Create a dynamic post title by the CRED form.
add_action('cred_save_data','func_custom_post_title',10,2);
function func_custom_post_title($post_id,$form_data) {

if ($form_data['id']==9999) {

$name = get_post_meta($post_id, 'wpcf-name', true);
$email = get_post_meta($post_id, 'wpcf-email', true);
$title= $name. '-' . $email;
$args = array('ID' => $post_id, 'post_title' => $title);
wp_update_post($args);

  }
}
#2787425

This is what i use. Instead of a function i use a static public function of my class.
My function is called but with only the post_id as a parameter.
Is it because of any Access control rules?

#2787427

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm not sure and that is custom programming which is beyond the scope of our support policy. Maybe the form_data attribute will be private and used within the Toolset hook.

You should use standard method as shared with the Doc and check if that help you to resolve your issue.