Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Role Emulation

I think it would be good to have the ability for allowed users to be able to browse the site in an emulated state as another role. This would be good to have so developers and designers wouldn't have to make extra users to test out additional layouts or ACL restrictions. I don't expect this to be a soon™ feature, but would definitely love to see this added at some point.


  • This would be a cool feature to have for support purposes, maybe even emulating user too. An emulate method could work something like this:

    User::emulate_role ('editor'); // emulate editor
    User::emulate_role (false); // disable emulation
    User::emulate_role (); // returns role name or false if not emulating
    User::emulate_user ($user_id); // emulate $user_id
    User::emulate_user (false); // disable emulation
    User::emulate_user (); // returns user ID or false if not emulating
    User::real_role (); // get real role, if emulating
    User::real_user (); // get real user ID, if emulating

    Would it need much else?

  • That is a pretty clean solution. My concern is how it would persist over multiple page requests. Maybe stick it in a cookie underconf('General','session_name') .'_emulated' and have the User init read that and start the emulation automatically? I'm having a hard time seeing a GET parameter being passed around properly anyways.

  • What about just setting a session variable?

    $_SESSION['elefant_user_emulating'] = $user_id;

    That way it's on the server exclusively :)

  • Right. Yes. That would be better.

  • Great idea. I think that would be very helpful.

Sign In or Register to comment.