Browse: Home / Snippets /

Change the displayed name of users in the Course Settings & Groups Users List Selection

Contents


Snippet #

Important: All snippets are provided as-is without support or guarantees. These snippets are provided as guidelines for advanced users looking to customize LearnDash. For any additional help or support with these snippets, we recommend reaching out to a LearnDash Expert.


// Changes the displayed login_name to email address in the Course Settings & Groups Users List selection
add_filter( 'learndash_binary_selector_item', function( $user_name, $user, $position, $selector_class ) {
    $userData = get_user_by( 'id', $user->ID );
    switch( $selector_class ) {
        // Groups Users Selection list
        case 'Learndash_Binary_Selector_Group_Users':
        case 'Learndash_Binary_Selector_Group_Leaders':
            return $userData->user_email;
        break;

        // Course Settings Users Selection list
        case 'Learndash_Binary_Selector_Course_Users':
        case 'Learndash_Binary_Selector_Course_Leaders':
            return $userData->user_email;
        break;

        default:
            return $user_name;
        break;
    }
}, 999, 4 );