wordpress check user against user roles

get_userdata( $user_id ) function is used to retrieve user information by user ID. $user = get_userdata( $user_id ); is used to get user data by user ID and store in a variable. $user_roles = $user->roles; retrieves the roles of the user. in_array( 'administrator', $user_roles ) checks if the user has the 'administrator' role. $current_user = wp_get_current_user(); is used to get the current user's data. $current_user_roles = $current_user->roles; retrieves the current user's roles. in_array( 'editor', $current_user_roles ) checks if the current user has the 'editor' role.