Skip Navigation

[Gelöst] Is there any way that we can perform CRED operation without using the CRED form?

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.

This topic contains 3 Antworten, has 2 Stimmen.

Last updated by Adriano vor 8 Jahre, 2 Monate.

Assigned support staff: Adriano.

Author
Artikel
#155367

Hey fellows here is the situation:
we have defined 2 custom types (person and company), also a custom type of NtoN relationship btw person and company. the defined person custom type has 1to1 relationship with USER in WORDPRESS. now what we need to do is to sync info of wordpress user registeration to custom type person, is there an API to perform this kind of task? or is there any way that we can perform CRED operation without using the CRED form?

#155508

Dear feimingH,

You will need to create a custom field to store the user ID in Person CPT. This connection can be done when a CRED form is submitted to add a Person. There is a hook called cred_submit_complete that lets you to execute some code when a form is submitted:

add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==101)  
{
$idUser = wp_create_user( $_POST['wpcf-user_name'], $_POST['password'], $_POST['wpcf-email_address'] );
add_post_meta($post_id, 'wpcf-user_id, $idUser, true);
}
}

The code above should be added in functions.php of your theme. You need to replace "101" with the correct ID of the CRED form and replace the variables to username, password and email. I also created a custom field in Persons called wpcf-user_id to store the wordpress user ID. The connection is ready, is it what you want to do?

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

#161596

Sorry for the delay.
Your answer realy helpful.

#161714

You are welcome.