^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_editable_user_ids()用法示例

Warning: This function has been deprecated. Use get_users() instead.

get_editable_user_ids( int $user_id,  bool $exclude_zeros = true,  $post_type = 'post' )

Gets the IDs of any users who can edit posts.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


描述


参数

$user_id

(int)
(Required)
User ID.

$exclude_zeros

(bool)
(Optional)
Whether to exclude zeroes.

Default value: true


返回值

(array) Array of editable user IDs, empty array otherwise.


源代码

File: wp-admin/includes/deprecated.php

function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );

	global $wpdb;

	if ( ! $user = get_userdata( $user_id ) )
		return array();
	$post_type_obj = get_post_type_object($post_type);

	if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
		if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
			return array($user->ID);
		else
			return array();
	}

	if ( !is_multisite() )
		$level_key = $wpdb->get_blog_prefix() . 'user_level';
	else
		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels

	$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
	if ( $exclude_zeros )
		$query .= " AND meta_value != '0'";

	return $wpdb->get_col( $query );
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-includes/pluggable.php:
    get_userdata()
  • wp-includes/load.php:
    is_multisite()
  • wp-includes/functions.php:
    _deprecated_function()
  • wp-includes/post.php:
    get_post_type_object()
  • wp-includes/wp-db.php:
    wpdb::get_col()
  • wp-includes/wp-db.php:
    wpdb::prepare()
  • wp-includes/wp-db.php:
    wpdb::get_blog_prefix()
  • Show 2 more uses


Used By

  • wp-admin/includes/deprecated.php:
    get_editable_authors()
  • wp-admin/includes/deprecated.php:
    get_others_unpublished_posts()

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈