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?
Thanks
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?
Thanks
here is how you could do it
OPTION1
create a custom role let's say "limited access" with no permisions in website(edit/delete/view) except to create his account, this would be your default role for users
then create a custom role let's say "premium access" with permision to view your content(or whatever)
In account settings add your custom field("access") with values you wish("limited", "premium").
/admin/config/people/accounts/fields
Add rulles module and create a custom rulle that on account creation/update if field_access == premium then update the role to "premium access".
After doing this you can manage the users from users roles
OPTION2
Again using rulles module you can check if your user has the value you need in his profile and redirect him to your page.
OPTION3
hook_init() and/or hook_boot() check if value in user account profile field and redirect him, something like that:
function hook_init(){
global $user;
$user_data=user_load($user->id);
if($user_data->field_access['LANGUAGE_NONE'][0]['value']=='limited'){
drupal_go_to('/content/limited');
}
}