LoginRequired
Provides an annotation for controller methods to check for logged in users. If a capability is passed to the constructor, the annotation will also check if the user has the capability.
Status codes ($statusCode) and redirect locations ($next) may also be passed as well.
Tags
Table of Contents
- $capability : string
- $next : string
- $statusCode : int
- __construct() : mixed
- getCapability() : string
- Returns the WP capability string.
- getNext() : string
- Returns a redirect location.
- getStatusCode() : int
- validateUser() : bool
- Calls the Wordpress function is_user_logged_in(). If a capability is set, also checks the current user's capability.
Properties
$capability
private
string
$capability
= ''
$next
private
string
$next
= ''
$statusCode
private
int
$statusCode
= 403
Methods
__construct()
public
__construct([string $capability = '' ][, int $statusCode = 403 ][, string $next = '' ]) : mixed
Parameters
- $capability : string = ''
- $statusCode : int = 403
- $next : string = ''
Return values
mixed —getCapability()
Returns the WP capability string.
public
getCapability() : string
Return values
string —getNext()
Returns a redirect location.
public
getNext() : string
Return values
string —getStatusCode()
public
getStatusCode() : int
Return values
int —validateUser()
Calls the Wordpress function is_user_logged_in(). If a capability is set, also checks the current user's capability.
public
validateUser() : bool