Advertisements

get_editable_user_ids

Definition:
function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {}

Parameters

  • int $user_id: User ID.
  • bool $exclude_zeros: Optional, default is true. Whether to exclude zeros.
  • $post_type

Source code

function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {

	_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );



	global $wpdb;



	$user = new WP_User( $user_id );

	$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 );

}

9468

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: