Restrict access for users without an avatar / user picture
truelove-nl - November 7, 2009 - 16:52
We want to restrict access to content (nodes, views) for registered users without an avatar / user picture. Has anyone has a suggestion how to accomplish this?
Thanks in advance.

that's currently not
that's currently not possible, but if you can make a module that gives a user permission if he uploads a picture...
than you can do whatever you want, cause you get total control over permissions.
rules could do the job, but there's no "picture" integration.
Thanks
Thanks for the instant reply. Creating a module is beyond my capabilities, but if anyone gives it a try, I'll be the first one to test it.
Restrict access best done by creating a role
The best way to control Permissions is by creating a new Role. I'm not a Drupal expert; this is only a suggestion of what I would try. Try this on a test site, not your live web site.
Download the Rules module and use it to change the Role of the User who uploads a picture.
========================================
Add a new Role: mynewrole (name it what you want).
========================================
Set Permissions for mynewrole.
========================================
Add a new Rule (Admin >Rules)
--Rule name: User picture added
--Rule event: User account details have been updated
--Rule condition: User has roles
------(Checks to see if user already has the role)
------User is updated user
------Check the box: Negate
------Check mark the role: mynewrole
------Weight: 0
--Rule condition: Check a truth value
----Weight: 1
----PHP evaluation
// Default value
$truth = 0;
// Do they have a picture?
if($account->picture) {
$truth = 1;
}
return $truth;
--Rule action: Add user role
-----Check mark the role: mynewrole
If Rules cannot access $account->picture
I was typing as vertazzar answered. If Rules cannot access $account->picture, I guess my idea would not work. Like I said, I never did it. Just that's what I would try.
Ashford