我会添加一个元键和值to each user first 然后添加meta_key 和meta_value 到get\\u users参数数组。
例如,可以调用您的元密钥showme 价值是"yes". 所以只要作者的元值是"no", get_users() 将排除该作者。
Add this code to your functions.php:
<?php // you might not need this line when pasting into functions.php
add_action( \'show_user_profile\', \'so_show_extra_radios\' );
add_action( \'edit_user_profile\', \'so_show_extra_radios\' );
function so_show_extra_radios( $user ) { ?>
<table class="form-table">
<tr>
<th>
<label for="showme">Show profile</label>
</th>
<td>
<input type="radio" name="showme" value="yes" <?php
if (esc_attr(get_the_author_meta(\'showme\', $user->ID)) == "yes")
echo "checked";
?>></input> Yes<br>
<input type="radio" name="showme" value="no" <?php
if (esc_attr(get_the_author_meta(\'showme\', $user->ID)) == "no")
echo "checked";
?>></input>
</td>
</tr>
</table>
<?php }
add_action( \'personal_options_update\', \'so_save_profile\' );
add_action( \'edit_user_profile_update\', \'so_save_profile\' );
function so_save_profile( $user_id ) {
if ( !current_user_can( \'edit_user\', $user_id ) ) return false;
if (wp_kses_post( $_POST[\'showme\'] ) == \'yes\')
update_usermeta( absint( $user_id ), \'showme\', "yes" );
else
update_usermeta( absint( $user_id ), \'showme\', "no" );
}
然后添加您的
meta_key 和
meta_value 作者中的参数。php(或任何检索作者配置文件的地方)
as described here.