1

I used this to get User list table columns Name.

users list table

add_filter( 'manage_users_columns', array($this , 'new_modify_user_table'));

public function new_modify_user_table( $column ) {
    $column  // columns Name array , Looking for this array out side Users page
}

But manage_users_columns hook is not fired outside "/wp-admin/users.php", that mean It work When I am on page "/wp-admin/users.php" , but it did not Work On outside users page.

so, How do I get User table Columns Name in My plugin? or on the outside "/wp-admin/users.php"

thankyou.

8
  • how do you want to use this columns if you are not as the "Users" page. edit your question to add more details.
    – mmm
    Jul 26 '18 at 5:39
  • Dear mmm, thank you for your question. I want to create a Plugin like "Admin Columns" (wordpress.org/plugins/codepress-admin-columns) so i need to know the columns Name outside users.php.
    – javmah
    Jul 26 '18 at 5:49
  • For Dynamically add a column you have to know all the columns name, but it is Very Unusual to go to users.php to fire manage_users_columns hook every time.
    – javmah
    Jul 26 '18 at 6:08
  • Columns can be added by other plugins. They only get added when that filter runs (and when the other plugins decides - they may do it generally (all admin), or they may add the filter only if in users.php.) Thus best you can do I think is assume default columns & that your plugin is in control of rest. You could apply_filters('manage_users_columns') yourself to the default data, you might 'see' some other fields added.
    – anmari
    Jul 26 '18 at 7:10
  • this columns list in only generated in the file "wp-admin/users.php" then a idea to retrieve the list is to call this page, read the list in the filter manage_users_columns and store the list in cache.
    – mmm
    Jul 26 '18 at 8:22
0

Yep! solved it.

require_once( ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php' ); 
$hmm = new WP_Users_List_Table( array( 'screen' => 'users' ) ); 
$hmm->get_column_info()[0] 
1
  • require_once( ABSPATH . 'wp-admin/includes/screen.php' ); print_r( get_column_headers('users') ) ; it will work too.
    – javmah
    Jul 28 '20 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.