I'm trying to promote my Wordpress users when they visit certain link but I'm not sure how to do that.
I found this function and placed it on the page where I want that change to be made. I though it might do the trick, but it won't:
function update_roles() {
global $wpdb;
$author = wp_get_current_user();
$author->remove_role( 'subscriber' );
$author->add_role( 'contributor' );
}
Any clues on how to do this?
wp_update_user( [ 'ID' =>get_current_user_id(), 'role' => 'contributor' ] );
You can use this code in your page template to change your user role.