I really needed to access, programmatically, the User Roles being referenced. This module only comes with a "Role name" display format, so I added two: one that prints the Role IDs (rid) and another that returns a serialized array of Role IDs (rid_array).

I think this is handy, because I specifically needed to compare the user roles being referenced in a node against the roles that the user has been assigned. Now that I can return a serialized array, I can unserialize and then compare, using PHP's array_keys() function on the $user->roles variable.

I tried just returning an array of Role IDs, but all that gets returned is the string "array", so it must be serialized.

Seems like this would be useful for other people, so I offer it here. Hopefully the module maintainer agrees and sees fit to include it in the next release? Here's a patch on 6.x-1.0

Comments

deekayen’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

johnv’s picture

Version: 6.x-1.0 » 7.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)

This feature is not in D7-version.

deggertsen’s picture

Issue summary: View changes
Status: Patch (to be ported) » Needs review
StatusFileSize
new964 bytes

Patch attached that fixes this issue in D7.

  • deekayen committed 6d82c93 on 7.x-1.x authored by deggertsen
    Issue #724692 by Offlein, deggertsen: Role ID Display Formatter Support
    
deekayen’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.