Skip Navigation

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

This support ticket is created Il y a 4 années. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 1 réponse, a 2 voix.

Dernière mise à jour par Luo Yang Il y a 4 années.

Assisté par: Luo Yang.

Auteur
Publications
#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
lien caché
and update the post author to the new user:
https://developer.wordpress.org/reference/functions/wp_update_post/