3

I have defined some user roles and I'm assigning them to users through the rules module. I have created a feature with the rules and the roles and moved them to another site. My problem is that the user roles get new IDs and that the IDs are hardcodet in the exportet rules. Therefore the rules assigns wrong roles and I don't want to fix that each time I install the feature.

Can I somehow hardcode the user roles programatically and let the rules module work on them? Is there a better solution for the problem?

It is more or less the same problem for taxonomies that also get assigned new IDs.

3 Answers 3

3

The Role Export module causes Role IDs to be hashes of Role Names — so the same Role Name will have the same Role ID on all sites. Great in conjunction with Features.

For Taxonomies, the UUID Features module may be helpful.

1

In short, this is a limitation in Core. Not everything has a machine name, and thus cannot be reliably exportable. Perhaps by D8's release everything will have UUID or a similar solution, allowing us to solve this. Then again, it's not a "magic bullet", as it comes with it's own set of issues, which is why we still have this problem around.

I have a question over here that revolves around how to handle this problem. There are no perfect solutions, but you have some good input over there.

1

This is a limitation of the features module. The makers of the features module have decided to use a so called machine name to identify exportables. Roles don't have a machine name. You can, however write your own module that exports roles based on the rid of the role. See the file API.txt in the feature module directory for an explanation about which hooks to implement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.