在Wordpress中将自定义组合框过滤器添加到管理员用户列表
我想在管理员用户列表面板中添加2个组合框。例如,第一个组合框是带有国家的组合框,另一个组合框是用户年龄。 所以我想添加这些组合以过滤用户列表 你能在这里照点光吗在Wordpress中将自定义组合框过滤器添加到管理员用户列表,wordpress,list,filter,Wordpress,List,Filter,我想在管理员用户列表面板中添加2个组合框。例如,第一个组合框是带有国家的组合框,另一个组合框是用户年龄。 所以我想添加这些组合以过滤用户列表 你能在这里照点光吗 谢谢。您可以将自己的字段添加到用户添加/编辑字段。 这个例子展示了如何添加一个地址输入字段,如果你得到了这个工作,试着用你需要的下拉列表切换它。如果这就是你所说的“组合框” function fb_add_custom_user_profile_fields( $user ) { ?> <h3><?php
谢谢。您可以将自己的字段添加到用户添加/编辑字段。
这个例子展示了如何添加一个地址输入字段,如果你得到了这个工作,试着用你需要的下拉列表切换它。如果这就是你所说的“组合框”
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' );
函数fb\u添加\自定义\用户\配置文件\字段($user){
?>
这就是我要找的:
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;
}