Hey @vargaszabolcs – Thank you for your answer. You are correct, Automattic is following the standards, but in this case, even WordPress is not following the correct approach since it updates the roles using directly the user meta instead of the wp_update_user function.
Unfortunately, this is kind of a habit in the community ??
To make it compatible at this point, simply add the following snippet to your functions.php file:
add_action( 'set_user_role', 'wp_webhooks_trigger_as_user_update', 10, 1 );
function wp_webhooks_trigger_as_user_update( $user_id ){
if( empty( $user_id ) ){
return;
}
$old_user_data = get_userdata( $user_id );
//Fire the profile update hook manually
do_action( 'profile_update', $user_id, $old_user_data );
}
All it does is to provide a fully functional call of the original profile_update hook call once the role was set using the WP_User::set_role()
function.
Hope this helps. If you require any further questions, feel free to let me know at any time. ??