Добавление пользовательских фильтров ComboBox в список пользователей-администраторов в Wordpress - PullRequest
1 голос
/ 28 сентября 2011

Я хочу добавить 2 поля со списком в панели администратора.Например, первым будет поле со списком стран, а другим - возраст пользователя.Поэтому я хочу добавить эти комбинации, чтобы отфильтровать список пользователей.

Не могли бы вы пролить немного света здесь?

Спасибо.

Ответы [ 2 ]

2 голосов
/ 31 мая 2012

Это то, что я ищу:

add_action('restrict_manage_posts','my_restrict_manage_posts');

        function my_restrict_manage_posts() {
            global $typenow;

            if ($typenow=='your_custom_post_type'){
                         $args = array(
                             'show_option_all' => "Show All Categories",
                             'taxonomy'        => 'your_custom_taxonomy',
                             'name'               => 'your_custom_taxonomy'

                         );
                wp_dropdown_categories($args);
                        }
        }
add_action( 'request', 'my_request' );

function my_request($request) {
    if (is_admin() && $GLOBALS['PHP_SELF'] == '/wp-admin/edit.php' && isset($request['post_type']) && $request['post_type']=='your_custom_post_type') {
        $request['term'] = get_term($request['your_custom_taxonomy'],'your_custom_taxonomy')->name;
    }
    return $request;
}
0 голосов
/ 25 мая 2012

Вы можете добавить свои собственные поля в поле добавления / редактирования пользователя.В этом примере показано, как добавить поле ввода адреса, если вы работаете, попробуйте переключить его с нужными вам выпадающими списками.Если это то, что вы имеете в виду под 'combobox'

function fb_add_custom_user_profile_fields( $user ) {
?>
    <h3><?php _e('Extra Profile Information', 'your_textdomain'); ?></h3>
    <table class="form-table">
    <tr>
    <th>
    <label for="address"><?php _e('Address', 'your_textdomain'); ?>
    </label></th>
    <td>
    <input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br />
    <span class="description"><?php _e('Please enter your address.', 'your_textdomain'); ?></span>
    </td>
    </tr>
    </table>
    <?php }
    function fb_save_custom_user_profile_fields( $user_id ) {
    if ( !current_user_can( 'edit_user', $user_id ) )
    return FALSE;
    update_usermeta( $user_id, 'address', $_POST['address'] );
    }
    add_action( 'show_user_profile', 'fb_add_custom_user_profile_fields' );
    add_action( 'edit_user_profile', 'fb_add_custom_user_profile_fields' );
    add_action( 'personal_options_update', 'fb_save_custom_user_profile_fields' );
    add_action( 'edit_user_profile_update', 'fb_save_custom_user_profile_fields' );
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...