好的,这是允许用户添加电话号码的代码。在函数中粘贴此完整代码。php文件。这将在用户配置文件中为“电话号码”添加新字段,并在WordPress admin中为Phone添加一列用户表。
function new_contact_methods( $contactmethods ) {
$contactmethods[\'phone\'] = \'Phone Number\';
return $contactmethods;
}
add_filter( \'user_contactmethods\', \'new_contact_methods\', 10, 1 );
function new_modify_user_table( $column ) {
$column[\'phone\'] = \'Phone\';
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 );
default:
}
return $val;
}
add_filter( \'manage_users_custom_column\', \'new_modify_user_table_row\', 10, 3 );
EDIT
要添加两列,需要进行一些更改。比较两种代码以了解。
function new_modify_user_table( $column ) {
$column[\'phone\'] = \'Phone\';
$column[\'xyz\'] = \'XYZ\';
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 );
case \'xyz\' :
return \'\';
default:
}
return $val;
}
add_filter( \'manage_users_custom_column\', \'new_modify_user_table_row\', 10, 3 );