Extra field and column in users WordPress

Put this code in the theme’s functions file -> following path:

/domains/your_domain/public_html/wp-content/themes/your_theme_name/functions.php



function new_contact_methods( $contactmethods ) {
    $contactmethods['phone'] = 'Phone Number';
	$contactmethods['birthdate'] = 'Birthdate';
	$contactmethods['handicap'] = 'Handicap';
    return $contactmethods;
}
add_filter( 'user_contactmethods', 'new_contact_methods', 10, 1 );


function new_modify_user_table( $column ) {
    $column['phone'] = 'Phone';
    $column['birthdate'] = 'Birthdate';
	$column['handicap'] = 'Handicap';
    return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );

function new_modify_user_table_row( $val, $column_name, $user_id ) {
     switch ($column_name) {
        case 'phone' :
            return get_the_author_meta( 'phone', $user_id );
            break;
        case 'birthdate' :
            return get_the_author_meta( 'birthdate', $user_id );
            break;
		case 'handicap' :
            return get_the_author_meta( 'handicap', $user_id );
            break;
        default:
    }
    return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );

 

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *

5 + 9 =