admin管理员组

文章数量:1122846

I used this to get User list table columns Name.

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.

I used this to get User list table columns Name.

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.

Share Improve this question edited Jul 26, 2018 at 6:10 javmah asked Jul 26, 2018 at 5:35 javmahjavmah 615 bronze badges 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 Commented Jul 26, 2018 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 Commented Jul 26, 2018 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 Commented Jul 26, 2018 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 Commented Jul 26, 2018 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 Commented Jul 26, 2018 at 8:22
 |  Show 3 more comments

1 Answer 1

Reset to default 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] 

本文标签: how to get WordPress admin user table columns name in my plugin