Hello. Thank you for contacting the Toolset support.
Well - as I understand you want to set the logged in user as the author of the post created using CRED form. If this is correct then, to set the post author on CRED form to submit action you can use CRED hook: cred_save_data
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)
{
$my_post = array(
'ID' => $post_id,
'post_author' => 1111
);
}
}
Where:
- Replace 9999 with your CRED form ID.
- Replace 1111 with post author ID.
Not exactly. I missed a part of the explanation, my bad.
The situation is following:
I'm creating a sort of pen pal service where users can register and save an introduction message for potentials pen pals. These messages along with some information about the author are displayed on front end, so other users can filter (by custom user fields I added) and choose who do they want to write.
It would be enough to use user profiles to display these messages on the front end, but your Views plugin doesn't provide filtering options for the users. So I decided I will create a post for each user and display them.
So my question is: how to create a post on user registration and make that user its author?
My guess was to use cred_submit_complete action, but this is as far as I went.
Yes both cred_save_data and cred_submit_complete hooks should work. You need to add your custom code within this hooks and need to create a new post and assign your registered user as your new post author.
Now I'm editing a user account and want to update post data on sumbit (for the post where this user set as an author).
I have the following code. I can update "status", but "language" does not change.
Language is set as checkboxed (multiple choice), status as a single checkbox.