Most people recommend setting up the hostname on a Linux box so that:
1) running ‘hostname‘ returns the short name (i.e. myhost) 2) running ‘hostname -f‘ returns the FQDN (i.e. myhost.prod.example.com) 3) running ‘hostname -d‘ returns the domain name (i.e prod.example.com)
After experimenting a bit and also finding this helpful Server Fault post, here’s what we did to achieve this (we did it via Chef recipes, but it amounts to the same thing):
make sure we have the short name in /etc/hostname:
myhost
(also run ‘hostname myhost‘ at the command line)
make sure we have the FQDN as the first entry associated with the IP of the server in /etc/hosts:
/**
* Checks if a particular user has a role.
* Returns true if a match was found.
*
* @param string $role Role name.
* @param int $user_id (Optional) The ID of a user. Defaults to the current user.
* @return bool
*/
function appthemes_check_user_role( $role, $user_id = null ) {
if ( is_numeric( $user_id ) )
$user = get_userdata( $user_id );
else
$user = wp_get_current_user();
if ( empty( $user ) )
return false;
return in_array( $role, (array) $user->roles );
}
// example use for the current user
if ( appthemes_check_user_role( 'customer' )
_e( "You've got access dude!", 'appthemes' );
else
_e( "Sorry man, no luck.", 'appthemes' );
// example use for a specific user
$user_id = 23;
if ( appthemes_check_user_role( 'customer', $user_id )
_e( "You've got access dude!", 'appthemes' );
else
_e( "Sorry man, no luck.", 'appthemes' );