This is really odd.

I have two file fields attached to a content type: field_restricted_file and field_public_file. The first is visible only to some roles; the second, to everyone. I have rules which,depending on whether the author ticks a "make public" box or not, copy content from one field to the other and remove it from the field with wrong visibility settings.

In my private-to-public rule, under Actions, Execute custom PHP, I have

$node->field_restricted_file[$node->language][0] = $node->field_public_file[$node->language][0];
unset ($node->field_public_file[$node->language][0]);

In the public-to-private rule the variables change place.

The odd thing is that it goes fine one way but not another. It's definitely not the conditions, because the copying line works fine in both cases. In fact, if I remove the second line just from the public-to-private rule, what happens is that I can make a private file public and delete the old copy just fine, and, going the other way, I get two copies the old one and the new one. However, if I reinstate the missing delete line, going from public to private, I lose the data in both fields!

This makes no sense. It seems to be reading the second line before the first. I've tried splitting up the two lines between two different rules with explicitly stated stated weights - still no joy. Does anybody have any idea, what might be causing this, and how I get around it? This is driving me nuts and threatening to derail the whole project. Please, help!

Thank you,

Pav