Rules/Roles/Checking entries for another account

Events happening in the community are now at Drupal community events on www.drupal.org.
joe.bearden's picture

I'm using Masquerade to allow people to use multiple accounts on our site.

I'd like to be able to use Rules when the secondary account is logged in to check the primary account for a role and take an action on the secondary account based on the answer.

Anyone know if/how this can be done?

Comments

Seems dangerous

itangalo's picture

The Masquerade module is, as far as I know, intended for developing purposes and letting developers/themers temporarily view the site through another user's eyes. Letting 'people' use the module sounds scary.

Anyway.

I don't think there are any variables exposed to Rules that can be used. It is possible (but not adviceable) that you can write some PHP code to fetch the UID for the primary user account, load it into Rules and then treat it as any other loaded user object.

Another approach, which doesn't involve Masquerade, is that you let users create completely separate accounts and use flags (or something) to connect them. (You could also use node or user references on profile nodes, if you use Content Profile.) If you have a more standard connection between two users it will probably be easier to load the related user data inside Rules.

Good luck!
//Johan Falk, NodeOne, Sweden

Thanks so much for the reply!

joe.bearden's picture

Thanks so much for the reply! It's great to get help and support from the community here, and it's what really makes Drupal practical.

Masquerade lets you set up particular accounts that normal users can Masquerade as, so there's no issue with them logging into an account they're not supposed to. It's just simpler for them than logging out of their primary account, logging in to their secondary account, logging out again, and back into their primary.

What you're describing is pretty much what I'd like to do, but lack the skill to implement.

  1. Create a hidden field inside the secondary account profile (I can set these manually if I can figure out how find the UID of the primary account--Isn't this just the number in the URL when you edit a user's profile?).
  2. Tell Rules to run a comparison when the user logs in to the secondary account (is UID:role 1 or 0?)
  3. Set the role on the secondary account (this much, at least, I can do.)

It's really step two that's beyond me, as I'm not really a PHP guy, and I don't really understand how to write a comparison within the Rules interface. Can you help?

Thanks!

Masquerade

Kargavibe's picture

Finaly i had found the option to enable the masquerade in the web page.
I gone: admin->structure->context->os_public->edit blocks->chech masquerade and then insert in footer bottom.

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: