get_editable_authors

Definition:
function get_editable_authors( $user_id ) {}

Parameters

  • int $user_id: User ID.

Return values

returns:List of editable authors. False if no editable users.

Defined filters

  • get_editable_authors
    apply_filters('get_editable_authors', $authors)

Source code

function get_editable_authors( $user_id ) {

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



	global $wpdb;



	$editable = get_editable_user_ids( $user_id );



	if ( !$editable ) {

		return false;

	} else {

		$editable = join(',', $editable);

		$authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );

	}



	return apply_filters('get_editable_authors', $authors);

}

9465

get_dashboard_url

Definition:
function get_dashboard_url( $user_id, $path = '', $scheme = 'admin' ) {}

Get the URL to the user’s dashboard.
If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site, the dashboard for the current site is returned. If the user cannot edit the current site, the dashboard to the user’s primary blog is returned.

Parameters

  • int $user_id: User ID
  • string $path: Optional path relative to the dashboard. Use only paths known to both blog and user admins.
  • string $scheme: The scheme to use. Default is ‘admin’, which obeys force_ssl_admin() and is_ssl(). ‘http’ or ‘https’ can be passed to force those schemes.

Return values

returns:Dashboard url link with optional path appended.

Defined filters

  • user_dashboard_url
    apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme)

Source code

function get_dashboard_url( $user_id, $path = '', $scheme = 'admin' ) {

	$user_id = (int) $user_id;



	$blogs = get_blogs_of_user( $user_id );

	if ( ! is_super_admin() && empty($blogs) ) {

		$url = user_admin_url( $path, $scheme );

	} elseif ( ! is_multisite() ) {

		$url = admin_url( $path, $scheme );

	} else {

		$current_blog = get_current_blog_id();

		if ( $current_blog  && ( is_super_admin( $user_id ) || in_array( $current_blog, array_keys( $blogs ) ) ) ) {

			$url = admin_url( $path, $scheme );

		} else {

			$active = get_active_blog_for_user( $user_id );

			if ( $active )

				$url = get_admin_url( $active->blog_id, $path, $scheme );

			else

				$url = user_admin_url( $path, $scheme );

		}

	}



	return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme);

}

9453

get_current_screen

Definition:
function get_current_screen() {}

Get the current screen object

Return values

returns:screen object

Source code

function get_current_screen() {

	global $current_screen;



	if ( !isset($current_screen) )

		return null;



	return $current_screen;

}

9447

get_current_blog_id

Definition:
function get_current_blog_id() {}

Retrieve the current blog id

Return values

returns:Blog id

Source code

function get_current_blog_id() {

	global $blog_id;

	return absint($blog_id);

}

9445

get_blogs_of_user

Definition:
function get_blogs_of_user( $user_id, $all = false ) {}

Get the blogs a user belongs to.

Parameters

  • int $user_id: User ID
  • bool $all: Whether to retrieve all blogs, or only blogs that are not marked as deleted, archived, or spam.

Return values

returns:A list of the user’s blogs. False if the user was not found or an empty array if the user has no blogs.

Defined filters

  • get_blogs_of_user
    apply_filters( 'get_blogs_of_user', $blogs, $user_id, $all )

Source code

function get_blogs_of_user( $user_id, $all = false ) {

	global $wpdb;



	$user_id = (int) $user_id;



	// Logged out users can't have blogs

	if ( empty( $user_id ) )

		return false;



	$keys = get_user_meta( $user_id );

	if ( empty( $keys ) )

		return false;



	if ( ! is_multisite() ) {

		$blog_id = get_current_blog_id();

		$blogs = array( $blog_id => new stdClass );

		$blogs[ $blog_id ]->userblog_id = $blog_id;

		$blogs[ $blog_id ]->blogname = get_option('blogname');

		$blogs[ $blog_id ]->domain = '';

		$blogs[ $blog_id ]->path = '';

		$blogs[ $blog_id ]->site_id = 1;

		$blogs[ $blog_id ]->siteurl = get_option('siteurl');

		return $blogs;

	}



	$blogs = array();



	if ( isset( $keys[ $wpdb->base_prefix . 'capabilities' ] ) && defined( 'MULTISITE' ) ) {

		$blog = get_blog_details( 1 );

		if ( $blog && isset( $blog->domain ) && ( $all || ( ! $blog->archived && ! $blog->spam && ! $blog->deleted ) ) ) {

			$blogs[ 1 ] = (object) array(

				'userblog_id' => 1,

				'blogname'    => $blog->blogname,

				'domain'      => $blog->domain,

				'path'        => $blog->path,

				'site_id'     => $blog->site_id,

				'siteurl'     => $blog->siteurl,

			);

		}

		unset( $keys[ $wpdb->base_prefix . 'capabilities' ] );

	}



	$keys = array_keys( $keys );



	foreach ( $keys as $key ) {

		if ( 'capabilities' !== substr( $key, -12 ) )

			continue;

		if ( 0 !== strpos( $key, $wpdb->base_prefix ) )

			continue;

		$blog_id = str_replace( array( $wpdb->base_prefix, '_capabilities' ), '', $key );

		if ( ! is_numeric( $blog_id ) )

			continue;



		$blog_id = (int) $blog_id;

		$blog = get_blog_details( $blog_id );

		if ( $blog && isset( $blog->domain ) && ( $all || ( ! $blog->archived && ! $blog->spam && ! $blog->deleted ) ) ) {

			$blogs[ $blog_id ] = (object) array(

				'userblog_id' => $blog_id,

				'blogname'    => $blog->blogname,

				'domain'      => $blog->domain,

				'path'        => $blog->path,

				'site_id'     => $blog->site_id,

				'siteurl'     => $blog->siteurl,

			);

		}

	}



	return apply_filters( 'get_blogs_of_user', $blogs, $user_id, $all );

}

9375