the code doesn't work

WPTurbo » Snippets » the code doesn't work
0

Created with:

Visibility: 

public

Creator: Mark Higgins

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project
					<?php
/**
 * Plugin Name: WP Plugin
 * Version: 1.0
 * Description: Adds sortable columns to the user admin page.
 */

// Add sortable columns to the user admin page
add_filter('manage_users_columns', 'wpturbo_add_user_columns');
add_filter('manage_users_sortable_columns', 'wpturbo_make_user_columns_sortable');

function wpturbo_add_user_columns($columns) {
    $columns['user_login'] = 'Username';
    $columns['user_email'] = 'Email';
    $columns['display_name'] = 'Display Name';
    $columns['user_registered'] = 'Registered Date';
    return $columns;
}

function wpturbo_make_user_columns_sortable($columns) {
    $columns['user_login'] = 'user_login';
    $columns['user_email'] = 'user_email';
    $columns['display_name'] = 'display_name';
    $columns['user_registered'] = 'user_registered';
    return $columns;
}
				

This updated code includes two functions: wpturbo_add_user_columns and wpturbo_make_user_columns_sortable.

The wpturbo_add_user_columns function adds the desired columns ('Username', 'Email', 'Display Name', and 'Registered Date') to the user admin page.

The wpturbo_make_user_columns_sortable function makes these columns sortable by specifying the corresponding column keys.

Now, when you visit the user admin page, you should see the newly added sortable columns.

Register an account to save your snippets or go Pro to get more features.