Skip Navigation

[Resolved] Write parent post title as value in custom field of child post on save

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

Last updated by philipG-3 6 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#592712

Hi there

I'm using the "BestWebSoft PDF & Print" plugin in order to print a receipt where it should state the post title of the parent post. Unfortunately, PDF & Print doesn't render Toolset-shortcodes - but it renders Toolset-created custom fields ...

I think the best solution would be to pull the parent post title and write it into a custom field of the child post on save.

I don't know, how to accomplish this via API Hook in functions.php ... meaning I don't know how to access one custom field-value and then overwrite a value of another custom field.

Or ... would you suggest another solution to this problem?


add_action('cred_save_data', 'write_parent_post_title',10,2);
function write_parent_post_title($post_id, $form_data)
{

...

}

Thanks for your help!
Philip

#592715

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand - You are already using CRED form to add/edit CPT content - correct?

We have Doc available with example here:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
[Click on "More" button to see examples ]

If you still have issue, I need exact details where problem URL which field value you would like to save to which field with which post type?

#592717
2.PNG
1.PNG

Hi Minesh

Thanks for your quick response.

Please login using this link (I don't know how to PM you...):
hidden link

Then see the CPT "ArbeitnehmerInnen" and "Jobs", created by Types ... a "Job" is a child of "ArbeitnehmerIn".

When rendering the PDF of a "Job"-post where the shortcode [wpv-post-title id="$arbeitnehmerin"] is placed (see image 1), the output just states the title of the actual "Job"-post (see image 2), so I think PDF & Print doesn't know what to do with "id=$arbeitnehmerin" ... right?

How can I solve this?

Thanks
Philip

#592720

... I didn't actually start creating those custom fields as I don't know wether this would be the right way anyway to solve this. If you can run some tests I'd be glad... the site is a sandbox-installation... so, no worries 🙂

#592790

Minesh
Supporter

Languages: English (English )

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

*** 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.

#595349

Hi Minesh

Sorry for the late response! Meanwhile I figured out a workaround that'll work... for now 🙂

Thanks for your help!
Philip