Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp is user admin

if ( current_user_can('administrator') ) {} // also others than admin w same capabilities
if ( is_user_admin() ){} // if it is admin
if ( is_admin() ){} //if the view is not the admin interface but the theme
Comment

wordpress is admin

// Determines whether the current request is for an 
// administrative interface page.
is_admin()
Comment

user is admin wordpress

if( ! function_exists( 'current_user_has_role' ) ){
    function current_user_has_role( $role ){
        return user_has_role_by_user_id( get_current_user_id(), $role );
    }
}

if( ! function_exists( 'get_user_roles_by_user_id' ) ){
    function get_user_roles_by_user_id( $user_id ) {
        $user = get_userdata( $user_id );
        return empty( $user ) ? array() : $user->roles;
    }
}

if( ! function_exists( 'user_has_role_by_user_id' ) ){
    function user_has_role_by_user_id( $user_id, $role ) {

        $user_roles = get_user_roles_by_user_id( $user_id );

        if( is_array( $role ) ){
            return array_intersect( $role, $user_roles ) ? true : false;
        }

        return in_array( $role, $user_roles );
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: remove last comma from string php 
Php :: yii2 migration add column 
Php :: auto generate password in php 
Php :: laravel images mimetypes validatiion 
Php :: pdo last insert id 
Php :: get featured image url 
Php :: Call to undefined method JeroenNotenLaravelAdminLteHelpersMenuItemHelper::isSearchBar( 
Php :: redirect http to https htaccess laravel 8 
Php :: laravel collection reverse 
Php :: wordpress is_archive 
Php :: how to check if php is connected to database 
Php :: hasany cakephp 
Php :: check if ajax request php 
Php :: php read file line by line 
Php :: php foreach reverse 
Php :: None of the supported PHP extensions (PgSQL, PDO_PgSQL) are available. 
Php :: if field is filled out acf 
Php :: In PackageManifest.php line 131: Undefined index: name laravel 7 
Php :: php make query string from array 
Php :: php xml to array 
Php :: enqueue wordpress 
Php :: php connect to postgresql 
Php :: get thumbnail alt wordpress 
Php :: how to get previous page name in php 
Php :: hide .php from url .htaccess 
Php :: php round down 
Php :: Add 2 days to the current date in PHP 
Php :: styling not working in laravel breeze 
Php :: how get the first item in foreach in laravel 
Php :: carbon minus 1 day 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =