I am using the following code (<https://developer.wordpress.org/reference/hooks/set_user_role/>) to sync user role between his blogs on a multisite installation.

My question is if this approach can lead to an infinite loop?

```
// Sync user role
add_action( 'set_user_role', 'sync_user_role', 10, 2 );
function sync_user_role( $user_id, $role ) {

    $blogs = get_blogs_of_user( $user_id );

    $blogs_count = count( $blogs );

    if ( $blogs_count > 1 ) {
        foreach ( $blogs as $blog ) {

            $user_blog = new WP_User( $user_id, '', $blog->userblog_id );

            $user_blog->set_role( $role );
        }
    }
}

```