Skip Navigation

[Resolved] Create a new CTP post when a user is created with user-registration a CRED form

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to crate a new post when new user is created.

Solution:
You can use CRED hook 'cred_save_data' to create the post on the fly.

You can find proposed solution with the following reply:
https://toolset.com/forums/topic/create-a-new-ctp-post-when-a-user-is-created-with-user-registration-a-cred-form/#post-406959

Relevant Documentation:
https://toolset.com/documentation/user-guides/cred-api/#csd
http://codex.wordpress.org/Function_Reference/wp_insert_post

This support ticket is created 7 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Tulio 7 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#406818

I am trying to create a CRED user-registration from that will create a new CTP post titled, the First Name, Last Name, and user ID of the newly created user.

I've read the post linked below that states you can't do both, as of December 2015.
https://toolset.com/forums/topic/create-with-cred-a-post-user-form-that-also-create-a-user-registration/

Hoping perhaps this has changed since then.

If this is just not possible still - can I redirect the user to a new page that has a second CRED new content form that has the Post title pre filled-in with the First name, Last Name, and user ID of the user created before the page redirect?

Thank you in advance for your time!

#406959

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can use CRED hook 'cred_save_data' to create the post on the fly.

For example - add the following code to your current theme's functions.php file:

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($user_id, $form_data)
{
    // Change your CRED Form ID
    if ($form_data['id']==9999){

$new_post = array(
                'post_type' => 'YOUR-POST-TYPE',
                'post_status' => 'publish',
                'post_title' => 'YOUR-POST-TITLE',
               );
                wp_insert_post($new_post);
       }
}

Where:
Replace '9999' with your CRED user form ID.

You can get POST data with "$_POST" or $form_data. Please replace your post_title and "post_type" values accordingly.

More info:
https://toolset.com/documentation/user-guides/cred-api/#csd
http://codex.wordpress.org/Function_Reference/wp_insert_post

I hope above information will help you to resolve your issue.

#412547

This was VERY helpful, thank you for your suggestion and references!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.