Tell us what you are trying to do?
Hello, I'm developing a site for members with different hierarchical levels, each level aprove other people's inputs and change their roles via CRED. I created several custom roles with Toolset Access. I've created a custom role for people who subscribe to the website. The manager (one Role) needs to approve the people who have signed up for the site.
The manager enters a page and accesses a view that filters all users with intermediate paper and can edit the data of those users. The editing of all the data is perfect, with the exception of ROLE.
My problem is to make available the edition of the ROLE in the CRED that the manager accesses. I have seen that there is a solution in this link.
https://toolset.com/forums/topic/create-two-roles/
But I'm not creating a new user, just making a page with a view for the Manager edit through a CRED other user.
Tentei o seguinte código, mas não funcionou.
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data) {
if ($form_data['id']==2320) {
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
wp_update_user ( array ( $user_id, 'role' => 'condomino_port_trouville' ));
}
}
I liked this solution and made a field that only the manager accesses and defines the new ROLE of the user.
// Modify new user role based on custom field selection in CRED
add_action('cred_save_data', 'cred_update_user_role_action',10,2);
function cred_update_user_role_action($user_id, $form_data) {
if ($form_data['id'] == 19872)
{
// modify the user role to match the selected option
$role = $_REQUEST['user_select_role'];
$u = new WP_User( $user_id );
$u->remove_role( 'pending' );
$u->add_role( $role );
}
}
But I'm not creating a new user.
Would you have a solution to this problem?
Is there any documentation that you are following?
https://toolset.com/forums/topic/create-two-roles/
https://toolset.com/forums/topic/edit-roles-cred/
https://toolset.com/forums/topic/allow-users-to-select-a-role-when-registeringediting-profile-with-cred-beta-3/
Is there a similar example that we can see?
No.
What is the link to your site?