I want to create a front-end form for 2-3 workers to go in and bulk add my "resource" CPT. But I want all of those added through this specific form to have my administrator account set as the author. I am not seeing a setting when I create a new post form to set an author, is this a possibility?
The best way to go here would be to use a small custom snippet, which uses wp_update_post() and updates the post author, in a cred_save_data hook.
1. The cred_save_data() hook is a function that allows you to add custom code to the moment when Forms saves a post in the database.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
2. wp_update_post() is a WordPress method to update a post.
https://developer.wordpress.org/reference/functions/wp_update_post/
Such function, to update the post author when a form submits, could look like this:
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']==12)//Change your form ID
{
$user_id = '1';//Change this to your own admin user id, usually, it is 1
$my_post = array(
'ID' => $post_id,
'post_author' => $user_id,
);
wp_update_post( $my_post );
}
}
Please study the above-linked DOCs for understanding the methods used, which will be required to maintain and expand above code, if required.
Thanks!
Thanks! I think this is exactly what I need. I should be able to get a final product from it.