Skip Navigation

[Resolved] Create a post type as guest, then create the user, assign him as the author

This support ticket is created 3 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 3 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1818403

Hello,

I have a questionnaire post type that ends up suggesting woocommerce products.
I am currently using 2 forms: first one creates the user, second one creates the post.
My client wants to switch these steps so that the user email/name/password are created at the end not the start.

Is there any workaround? I don't mind creating a "fake" temporary user, assign him as the author of the post, but then how can I change email/password at the end of the second form?

I would also want to avoid switching these fields to user fields...

If you can suggest a better way I'll be more than happy.

Thanks

#1820431

Hello,

It needs custom codes, for example:
one post form for creating new post + one user form for creating new user:
1) After you submit the post form, the post author is your self, and redirect to the new post
2) In this post content, display the user form, in this user form, output a hidden generic field, field value is current post ID,
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_generic_field
After you fill and submit the user form, send the email, and use action hook cred_save_data to trigger a PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

In this PHP function, get the hidden generic field post ID value
hidden link
and update the post author to the new user:
https://developer.wordpress.org/reference/functions/wp_update_post/

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