I want to let a guest create a CPT post and afterwards create him as a user and register him as the author of the post
Steps:
1. guest user to enter data into a Toolset CPT form
2. On submit the post is stored (guests will be allowed to create posts with Toolset Access), and automatically taken to next step
3. The Id for the new post is displayed to the Guest and he is prompted to enter a password (new form?)
4. On submit a new user id is created (username = post Id, password = what guest entered) (php-code)
5. The post author is updated with username (php-code)
When the user later returns to the site he can login using the “post id” as username (from step 3) and the password he entered (from step 5).
Example to illustrate:
Screen 1 (the post):
Enter some data : ___________
Enter more data: ___________
SUBMIT-button
Screen 2:
The case Id created is: 12345
Enter your password: ______________
SUBMIT-button
User can later login with user-id: 12345 and the password entered - to display the post from screen 1 data (as an author)
Questions:
A. Step 1+2 is standard Toolset, but how can I jump to a new form and display the Id given (step 3) ??
B. I assume I will be able to code step 4+5 with PHP. Any hooks I can use ??
Your input is appreciated
Is there any documentation that you are following?
Basically for your approach you need to create two separate form one for the post (post form) and another for the user (user form)/
Regarding your questions:
A. Step 1+2 is standard Toolset, but how can I jump to a new form and display the Id given (step 3) ??
- From the post form you need to add a redirect to a specific page in the form settings, The specific page will be the page where the user form will be displayed
- In order to pass the Post information from post form to the user form, Make use of the API <srong>cred_success_redirect and the WordPress Query args
eg:
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
// Allow to be run on the specific form
if ($form_data['id']==86)
$arr = array('username' => $post_id );
$url = add_query_arg($arr, $url);
return $url;
}
B. I assume I will be able to code step 4+5 with PHP. Any hooks I can use ??
- A minor adjustment needs to be done in the user form. Instead of the username field use the cred_generic_field, as this can be an hidden field also gets the value directly from url using the url param attribute
I struggle with the implementation of part B (cred_generic_field-part). I lack information/training about how to use the cred-fields. The programmers reference documentation doesn't help me. I have searched for how-to tutorials but havent found any ?!
Sure i can help can you let me know what is not clear in the document or where i can help.
Just in case if you are struggling with adding parameters to the cred_generic_fields you should enable the Expert mode in the form to see the form code where you can alter the field parameters.
You can also directly use my code for the generic field, Turn on the Expert mode in the form edit screen, Remove the default username field and replace it with the generic field code from my previous reply that should help as well.
Hi Raja - your support is highly appreciated ! I have now succeeded in creating a new user (step B).
What I still need is to also be able to display the parameter transfered in the URL (in the form). Currently this value goes to the login_login field (hidden). How can this be achieved?
I have also searched for tutorials/documentation that explains how to use "expert"-mode in the form. Does it exist?
You can turn on the Expert mode in form editor please check the attached screenshot, If you are stuck share temporary access to the site. let me try to help you with the setup. I have enabled private fields to securely share the details.