I am using rules to implement an "email subscription" feature where users can opt in to having new content of a particular content type emailed out to them (so they can read on a Blackberry which can't access the site). This works well but in my original setup, raises an error whenever the user uploads a user picture (avatar). This happens to all users, all of the time when uploading user pictures, irrespective of whether they opt in or out of the email subscription:

The specified file temporary://filename.jpg could not be copied, because no file by that name exists. Please check that you supplied the correct filename

In fact the picture upload has worked, but this error tends to confuse users, who then think their picture upload has failed.

At first sight this looks like an issue with the temporary directory but this is set correctly to /tmp on my system (Ubuntu Linux).

I've found a workaround.

I have one rule triggered "after updating an existing user account" to grant a "send me emails" role if the user has ticked a taxonomy field on their profile to opt in, and a similar one to do the reverse. I need the rules because non-privileged users can't directly alter their own roles.

These rules are the problem. But if I instead choose to fire them "before saving a user account", keeping everything else the same, they still work and the users no longer see the error.

The actual emailing is done by a "send mail to all users of a role" rule triggered on e.g. "after saving new content" - no problems there.

Comments

soul_discharge’s picture

I am having the same issue here as well. I have a rule granting a user a role after updating a field in their account profile. My users receive the same error as well after updating their user picture. Just like Matthew I ended up resolving the issue by changing the event method to "Before saving a user account". Is there a particular reason why this happens?

khanz’s picture

Version:7.x-2.3» 7.x-2.6

Facing exactly same error with Drupal7.26 and Rules 2.6. Changing the event method to "Before saving a user account" fixes the error. Though i am curious why this happens.

tedbow’s picture

Version:7.x-2.6» 7.x-2.7

I can confirm that I have same problem in 7.x-2.7 and 7.x-2.6.

Same method above fixes it.

Pafla’s picture

Hi

I am having the same issue.

My rule is "Role Superuser appoved":
Event - After updating an existing user account
Conditions - User has role(s) Parameter: User: [account], Roles: Superuser
Actions - Remove user role Parameter: User: [account], Roles: User

When adding the role "Superuser" to a user, the User picture (Avatar) disapere, but not the file on server.
And when uploading a new avatar the same error occurs.

If I disable this rule.
And add the role "Superuser" and remove the role "User" manually, then no problems.

What is the difference between "After updating an existing user account" and "Before saving a user account"?

Pafla