Skip Navigation

[Resolved] CRED API for User Forms?

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

Our next available supporter will start replying to tickets in about 1.05 hours from now. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by scottL-3 7 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#448432

I am trying to: create users from a CRED user form but I want to set their username to email address and set nickname and displayname to first name.

Is this possible with CRED forms alone? If not, is there an API for user forms? The CRED API documentation seems to only cover post forms.

I'd also like to change the wording on the password hint to 8 characters instead of 12. I can force this with javascript and/or CSS but it'd be nice to get it correct in the first place instead of correcting it.

I managed to put email address in as username by asking for username in the username part of the form but I don't want to ask the user for email twice and I don't want to ask for nickname or displayname at all, I just want to get the first name and save it as first name, display name and nickname. This would be sort of like setting the cred_field value for the display name and nickname to the value of the first name field but it isn't known when the form is being rendered so it needs to be set when the form is submitted.

#448527

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Scott,

Thank you for contacting our support forum.

Yes you can actually do this with our CRED API save data hook.

Take a look at this example.

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($new_user_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==1370)
    {
        if(isset($_POST['first_name']) && isset($_POST['last_name'])){
        	update_user_meta( $new_user_id, 'nickname', $_POST['first_name']."".$_POST['last_name']);
        }
        
        }
    }

Where it updates the user nickname to the first and last name.

Please let me know if this example helps.
Thanks,
Shane

#448567

Thanks Shane, this worked great and I was able to add the other things I needed it to do. All the CRED API examples for cred_save_data are for posts, not users. It would be good to add an example like this one into the documentation.

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