79268524

Date: 2024-12-10 14:05:40
Score: 0.5
Natty:
Report link

Ok so after a lot of frustration I got this to work BUT as for why it works I'm a little vague.

My parent post ID was saved as a numeric in the child post. The child post is editable by the user who fills out a cf7 form and submits it. On submit a hook is fired and data is saved etc. The aim was to also have a single field in the parent post (in the backend) update to register that the user has submitted the form by changing the value of a status field.

My child form loads the post date into an array using

$submission = WPCF7_Submission::get_instance();
$data = $submission->get_posted_data();

Then I assign and access the elements with ;

$parentid= $data['parentid']; //as parentid is saved to the child post

This for some reason does not want to pass the id to the variable (even though for every other variable i have it works just fine.

instead I have to directly assign the parentid variable outside of the array using;

$parentid = get_post_meta( $post_id, 'parentid', true );
$postfield = 'post_status';
$newvalue = 'new status setting';
update_post_meta($parentid, $postfield, $newvalue);

it works but i would still like to know why and what was going wrong?

it feels like i'm missing something very simple trying to add 2+2 but instead having to do 1+1+1+1!

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Stu