Delay action unltil the untill previous (hoocked) action is completed

Hooks fire in order so you can lower the priority to make it run after a previous one. However, if it is a different hook altogether you will have to see in which order they run to see which one you need to use.

add_action( 'profile_update', 'my_custom_function', 15, 2 );

function my_custom_function( $user_id ) {

    //get data from the updated user
    $user_info = get_userdata( $user_id );
          
                  
                 
    //check if user has the role XXX
    if ( in_array( 'my_custom_role', (array) $user_info->roles ) ) {
        //do something

    }else {
        //do something else
    }

}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)