Skip Navigation

[Resolved] save the url of a custom post type to a user custom post field

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

Problem:
save the url of a custom post type to a user custom post field

Solution:
You can use Toolset form hook "cred_save_data" in order to save the custom field value.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/save-the-url-of-a-custom-post-type-to-a-user-custom-post-field/#post-1115039

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This support ticket is created 6 years, 3 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
- 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 6 replies, has 2 voices.

Last updated by Johan Marneweck 6 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1114370

So I have a form where the user creates a custom post: 'candidate'.
I want to save the url of this newly created custom post to the user as the value of a custom user field: 'candidate-url'

I see you have some hooks that I can trigger something to occur after the 'candidate' post is saved, but my PHP knowledge is terrible and I can't seem to figure out how one would do this.

Please help.

#1114941

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - you can use Toolset Form hook cred_save_data to save the newly created post url to user custom field.

If you can share problem URL where you added your form and access details, I can surly help.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#1115004

Sent you the details

#1115027

Minesh
Supporter

Languages: English (English )

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

Well - the URL not loading.

I keep getting timeout error.

ERR_CONNECTION_TIMED_OUT
#1115030

hidden link this not loading on your end? Working on my end.

#1115039

Minesh
Supporter

Languages: English (English )

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

Could you please try following code.

Add following code to your current theme's functions.php file and check your issue.

add_action('cred_save_data', 'func_update_candidate_url',10,3);
function func_update_candidate_url($post_id, $form_data){
    global $current_user;

    if ($form_data['id']==999){
		
               $url = get_permalink($post_id);
               update_user_meta( $current_user->ID, 'wpcf-candidate-url', $url);
              
		
    }
}

Where:
- replace 999 with your original form ID

#1118915

My issue is resolved now. Thank you!