I'm a web designer and sorry for this simple php question, but wanted to know how to add more than one column into the wordpress users dashboard using the same function.This is the code I'm using to add one new column:
/**
* Adds a new column to the user display dashboard.
*/
function theme_add_user_new-column1_column( $columns ) {
$columns['new-column1'] = __( 'New Column 1', 'theme' );
return $columns;
}
add_filter( 'manage_users_columns', 'theme_add_user_new-column1_column' );
/**
* Populates the "New Column 1" column with the specified user's "New Column 1" information.
*/
function theme_show_user_new-column1_data( $value, $column_name, $user_id ) {
if( 'new-column1' == $column_name ) {
return get_user_meta( $user_id, 'new-column1', true );
}
}
add_action( 'manage_users_custom_column', 'theme_show_user_new-column1_data', 10, 3 );
I check the documentation, but the "||" and the "&&" was a little bit confusing for me. Or should use the array function? Thanks for any help.
Got and sharing the answear...
/**
* Adds a new column to the user display dashboard.
*/
function theme_add_user_column( $columns ) {
$columns['new-column1'] = __( 'New Column 1', 'theme' );
$columns['new-column2'] = __( 'New Column 2', 'theme' );
return $columns;
}
add_filter( 'manage_users_columns', 'theme_add_user_column' );
/**
* Populates the "New Columns" column with the specified user's "New Columns" information.
*/
function theme_show_user_new-column_data( $value, $column_name, $user_id ) {
if( 'new-column1' == $column_name ) {
return get_user_meta( $user_id, 'new-column1', true );
}
if( 'new-column2' == $column_name ) {
return get_user_meta( $user_id, 'new-column2', true );
}
}
add_action( 'manage_users_custom_column', 'theme_show_user_new-column_data', 10, 3 );
0 comments:
Post a Comment