mardi 3 novembre 2015

Using if statement inside php function

I'm a web design 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.

Aucun commentaire:

Enregistrer un commentaire