Thanks for the update and glad that you were able to create the list of users.
To show the user profile page, you can follow these steps:
1. Create a new page and name it something like "User Profile".
2. In your view to show the list of users, you can include a link to each user's profile page, using the HTML and shortcodes like this:
<a href="[wpv-post-url item='123']?id=[wpv-user field='ID']">Vedi il profilo</a>
Please replace 123 with the ID of the page "User Profile" created in step 1.
When this individual link will be clicked, the visitor will be taken to the user profile page, with the selected user's ID passed in the URL parameter 'id', for example:
{yourwebsite.com}/user-profile/?id=123
{yourwebsite.com}/user-profile/?id=456
3. In this "User Profile" page's content you can include the shortcodes for the user information and user fields as needed:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-user
https://toolset.com/documentation/customizing-sites-using-php/functions/
Note: To get the target user's ID from the URL parameter 'id', you can use the shortcode [wpv-search-term param='id'].
For example:
User First Name: [wpv-user field="user_firstname" id="[wpv-search-term param='id']"]<br>
User Last Name: [wpv-user field="user_lastname" id="[wpv-search-term param='id']"]<br>
User Email: [wpv-user field="user_email" id="[wpv-search-term param='id']"]<br>
User Custom Field: [types usermeta="user-custom field" user_id="[wpv-search-term param='id']"][/types]
And to allow the admin or specific role users to edit other user's role, you can create a new user edit form. In the form, you don't have to include any field, the "cred_save_data" hook can be used to programmatically change the user's role, when form is submitted.
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data )
add_action('cred_save_data', 'func_update_user_role_action',10,2);
function func_update_user_role_action($user_id, $form_data) {
if ($form_data['id'] == 12345) {
// modify the user role to match the selected option
$u = new WP_User( $user_id );
$u->remove_role( 'contributor' ); // role name to remove
$u->add_role( 'subscriber' ); // role name to add
}
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
In the code, you'll remove "12345" with the actual user form ID and replace 'contributor' and 'subscriber' with the actual role name to remove and add, respectively.
And in the user profile page, you can include this edit user form, using the shortcode so that the form edits the user whose ID is available in the URL parameter 'id':
[cred_user_form form='test-user-edit-form' user='[wpv-search-term param='id']']
Note: You'll replace "test-user-edit-form" with the actual name of your user form.
Important: If you're not already using the Toolset Access plugin, you'll need to activate it, to control which user roles can use this user edit form, to change the role.
( ref: https://toolset.com/lesson-placement/lesson-placements-1621521-1612073/ )