Skip Navigation

[Resolved] changing authorship of posts on submitting form

This support ticket is created 4 years, 5 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by peterv-6 4 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#1715153

I had some help from Minesh on this previously here:

https://toolset.com/forums/topic/automatically-transferring-authorship-of-posts-on-submitting-cred-form/

I have tried what was suggested.. also referencing another support ticket and added the following code to my functions file

}
/**
* for transferring ownership of funder profiles
*/

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']== 62276)

{
$my_post = array(
'ID' => $post_id,
'post_author' => get_current_user_id(),
);

}
}

It unfortunately didn't work.. any ideas/suggestions?

#1715269

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Peter,

Thank you for getting in touch.

Try adding the following to your post.

// Update the post into the database
wp_update_post( $my_post );

Thanks,
Shane

#1715495

That did the trick. My issue is resolved now. Thank you!