Browse: Home / Snippets /

Remove Enrolled Groups/Courses column from Users listing

Contents


Snippet #

// Remove the Filter selectors shown at the top of the Users listing.
add_filter( 'learndash_listing_selectors', function( $selectors, $type ) {
	if ( 'user' === $type ) {
		if ( isset( $selectors['course_id'] ) ) {
			unset( $selectors['course_id'] );
		}

		if ( isset( $selectors['group_id'] ) ) {
			unset( $selectors['group_id'] );
		}
	}

	// Always return $selectors;
	return $selectors;
}, 30, 2 );

// Remove the Courses/Groups column. 
add_filter( 'learndash_listing_columns', function( $columns, $type ) {
	if ( 'user' === $type ) {
		if ( isset( $columns['groups_courses'] ) ) {
			unset( $columns['groups_courses'] );
		}
	}

	// Always return $columns;
	return $columns;
}, 30, 2 );


// Legacy filters for older versions of LearnDash


add_action( 'init', function() {
	// Removes the Course and Group selects shown above the table listing
	remove_action( 'restrict_manage_users', 'learndash_add_user_nav_filter', 99 );

	// Removes the Course and Group columns
	remove_filter( 'manage_users_columns', 'learndash_user_list_columns' );

	// Removes the the Course and Group column output. 
	remove_filter( 'manage_users_custom_column', 'learndash_user_list_column_content', 10, 3 );
}, 100);