author_can

Advertisement

Summery Summery

Whether the author of the supplied post has a specific capability.

Syntax Syntax

author_can( int|WP_Post $post, string $capability )

Parameters Parameters

$post

(Required) Post ID or post object.

$capability

(Required) Capability name.

Return Return

(bool) Whether the post author has the given capability.

Source Source

File: wp-includes/capabilities.php

 * @param int    $blog_id    Site ID.
 * @param string $capability Capability name.
 * @param mixed  ...$args    Optional further parameters, typically starting with an object ID.
 * @return bool Whether the user has the given capability.
 */
function current_user_can_for_blog( $blog_id, $capability, ...$args ) {
	$switched = is_multisite() ? switch_to_blog( $blog_id ) : false;

	$current_user = wp_get_current_user();

	if ( empty( $current_user ) ) {
		if ( $switched ) {
			restore_current_blog();
		}
		return false;
	}

Advertisement

Changelog Changelog

Changelog
Version Description
2.9.0 Introduced.

Advertisement

Leave a Reply