Site Access control through a particular user field I am trying to only grant user the access to the site if one of the user fields have a particular value.

If not, the site should show an access denied.

Is there an efficient way to achieve this?
Let's say there is a specific path you want this rule to apply to, e.g. /special

&lt;?php

function my_module_menu()
{

    $items['special'] = array(
        'title' =&gt; 'Special Page',
        'page callback' =&gt; 'special_page',
        // Permission in next line will be overridden by the check inside the page callback function.
        'access arguments' =&gt; array('access content'),
        'type' =&gt; MENU_SUGGESTED_ITEM,
        );
}

function special_page()
{
    global $user;
    $query = new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type', 'user');
    $query-&gt;propertyCondition('uid', $user-&gt;uid, '=');
    $query-&gt;fieldCondition('field_special_field', 'value', 'required_value', '=');
    $query-&gt;range(0, 1);
    $result = $query-&gt;execute();

    if (isset($result['user'])) {
        // User meets the condition
        // Do whatsoever, show special content ..

    } else {
        // Deny access
        drupal_access_denied();

    }
}

?&gt;


Make sure to download and enable the Entity API module to use the above code.