Мне нужно отобразить сортируемый столбец «Компании» на странице WP-Admin «Все пользователи». Я использую Woocommerce. Я изменил код ниже и смог добавить столбец «Компании» и сделать его сортировкой. Я могу заполнить столбец с помощью данных: < /p>
get_the_author_meta( 'user_firstname', $user ); // https://developer.wordpress.org/referen ... thor_meta/
// I tried using company and user_company but they didn't work
< /code>
get_the_athor_meta работает со многими различными значениями, но я не думаю, что она может привлечь компанию, потому что компания - это поле по умолчанию, добавленное Woocommerce. Мой полный код ниже. Как я могу показать компанию? Кроме того, как мне изменить порядок этих столбцов? Я хочу показать имя пользователя, имя, компанию и электронное письмо в этом порядке. < /P>
/*
* Create a column & remove some of the default ones
* @param array $columns Array of all user table columns {column ID} => {column Name}
*/
add_filter( 'manage_users_columns', 'rudr_modify_user_table' );
function rudr_modify_user_table( $columns ) {
unset( $columns['role'] ); // Remove role column
unset( $columns['posts'] ); // Remove posts column
$columns['company'] = 'Company'; // Add new company column
return $columns;
}
/*
* Fill our new column with the company name of the users (if they have a company name in their profile)
* @param string $row_output text/HTML output of a table cell
* @param string $column_id_attr column ID
* @param int $user user ID (in fact - table row ID)
*/
add_filter( 'manage_users_custom_column', 'rudr_modify_user_table_row', 10, 3 );
function rudr_modify_user_table_row( $row_output, $column_id_attr, $user ) {
switch ( $column_id_attr ) {
case 'company' :
// return get_the_author_meta( 'company', $user );
// company is not included here: https://developer.wordpress.org/referen ... thor_meta/
// Need to use WooCommerce to find it but below is not working:
return get_user_meta( get_current_user_id(), 'company', true );
break;
default:
}
return $row_output;
}
/*
* Make our "Company" column sortable
* @param array $columns Array of all user sortable columns {column ID} => {orderby GET-param}
*/
add_filter( 'manage_users_sortable_columns', 'rudr_make_company_column_sortable' );
function rudr_make_company_column_sortable( $columns ) {
return wp_parse_args( array( 'company' => 'registered' ), $columns ); // This has an issue
}
Подробнее здесь: https://stackoverflow.com/questions/635 ... users-page
Отображать Сортус Службу компании на странице WP-ADMIN All Users ⇐ Php
Кемеровские программисты php общаются здесь
-
Anonymous
1752239803
Anonymous
Мне нужно отобразить сортируемый столбец «Компании» на странице WP-Admin «Все пользователи». Я использую Woocommerce. Я изменил код ниже и смог добавить столбец «Компании» и сделать его сортировкой. Я могу заполнить столбец с помощью данных: < /p>
get_the_author_meta( 'user_firstname', $user ); // https://developer.wordpress.org/reference/functions/get_the_author_meta/
// I tried using company and user_company but they didn't work
< /code>
get_the_athor_meta работает со многими различными значениями, но я не думаю, что она может привлечь компанию, потому что компания - это поле по умолчанию, добавленное Woocommerce. Мой полный код ниже. Как я могу показать компанию? Кроме того, как мне изменить порядок этих столбцов? Я хочу показать имя пользователя, имя, компанию и электронное письмо в этом порядке. < /P>
/*
* Create a column & remove some of the default ones
* @param array $columns Array of all user table columns {column ID} => {column Name}
*/
add_filter( 'manage_users_columns', 'rudr_modify_user_table' );
function rudr_modify_user_table( $columns ) {
unset( $columns['role'] ); // Remove role column
unset( $columns['posts'] ); // Remove posts column
$columns['company'] = 'Company'; // Add new company column
return $columns;
}
/*
* Fill our new column with the company name of the users (if they have a company name in their profile)
* @param string $row_output text/HTML output of a table cell
* @param string $column_id_attr column ID
* @param int $user user ID (in fact - table row ID)
*/
add_filter( 'manage_users_custom_column', 'rudr_modify_user_table_row', 10, 3 );
function rudr_modify_user_table_row( $row_output, $column_id_attr, $user ) {
switch ( $column_id_attr ) {
case 'company' :
// return get_the_author_meta( 'company', $user );
// company is not included here: https://developer.wordpress.org/reference/functions/get_the_author_meta/
// Need to use WooCommerce to find it but below is not working:
return get_user_meta( get_current_user_id(), 'company', true );
break;
default:
}
return $row_output;
}
/*
* Make our "Company" column sortable
* @param array $columns Array of all user sortable columns {column ID} => {orderby GET-param}
*/
add_filter( 'manage_users_sortable_columns', 'rudr_make_company_column_sortable' );
function rudr_make_company_column_sortable( $columns ) {
return wp_parse_args( array( 'company' => 'registered' ), $columns ); // This has an issue
}
Подробнее здесь: [url]https://stackoverflow.com/questions/63518891/display-sortable-company-column-on-the-wp-admin-all-users-page[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия