Skip Navigation

[Resolved] Setting author of post on front end post submission form

This support ticket is created 3 years, 10 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.

This topic contains 1 reply, has 1 voice.

Last updated by matthewL-7 3 years, 10 months ago.

Author
Posts
#1892745

Hi

I am using the code snippet mentioned here:
https://toolset.com/forums/topic/change-author-attribution-on-cred-form-submitted-content/#post-609667

But for some reason its not working.

The exact code I am using is:

add_action('cred_save_data', 'func_set_custom_author',10,2);
function func_set_custom_author($post_id, $form_data){
// if a specific form
    if ($form_data['id']==66944){
            $my_post = array(
                        'ID' => $post_id,
                        'post_author' => 51
                        );
            // Update the post into the database
            wp_update_post( $my_post );
  
    }
}

66944 being my form ID and 51 being the user I want all posts to be assigned to on this form submission. This form is on the front end and available for guests to complete.

Thanks.

#1892749

My issue is resolved now. Thank you!