Skip Navigation

[Résolu] Is there any way how to combine post and user forms?

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

Auteur
Publications
#574242

Hi,

I have a CRED form, which can be filled by registered users. But I also want to have it filled by guests so they can in the same form register to the site. I need an e-mail, name and phone number from them, the password will be automatically created. Is it possible?

#574351

Dear Dave,

There isn't such a built-in feature within CRED form, one CRED form can only do one thing:
1) CRED form for creating user, can create a wordpress user
2) CRED form for creating post, can create a post

In your case, it needs custom codes, for example:
1) Create a CRED form for creating post,
2) Put above CRED form into a page, for guest to submit the CRED form
3) When guest submit the CRED form, use action hook "cred_save_data" to trigger a PHP function
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
4) In this PHP function do these:
a) check if current user is a guest user
https://developer.wordpress.org/reference/functions/is_user_logged_in/
b) If it is a guest, then get the value of e-mail, name and phone number
https://developer.wordpress.org/reference/functions/get_post_meta/
c) Generate the password:
https://developer.wordpress.org/reference/functions/wp_generate_password/
d) And create a new wordpress user:
https://codex.wordpress.org/Function_Reference/wp_create_user