• Hi,

    I have need to modify the administrative interface based upon the role (WP2) of the currently logged in user.

    How can I retrieve this information?

    Is it possible to substitute, or modufy the editing interface for posts/pages via a plugin (preferable), or does this require hacking around (yuk) in the core code?

    I understand that it is possible to add elements to the admin interface via plugins, but not sure on modifying or removing parts of the core interface.

    Thanks in advance.

    Rob

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can use the global variable $current_user. This is an instance of a WP_User. Look in capabilities.php for the interface of this class. Each instance carries a roles member variable.

    You can use the actions simple_edit_form and edit_form_advanced to add items to the edit post interface. I bet there is also one on the edit page interface, but don’t know for sure.

    Thread Starter roblgs

    (@roblgs)

    Cheers McShelby… will take a look

    Rob

    Thread Starter roblgs

    (@roblgs)

    Well, almost, but not quite…

    $current_user includes what is being reported as an array that is

    $current_user[‘wp_capabilities’] that must include the info that I want, but I’m not clear on how to get it out. Although reported as an array, it’s not behaving as such… a foreach loop doesn’t yield anything.

    I need another nudge in the right direction…

    TIA

    Rob

    Thread Starter roblgs

    (@roblgs)

    Thanks syndromes… again a good pointer… unfortunately I’m just plain dense when it comes to objects.

    For now I can simulate the level of switching based upon specific capabilities using

    if (current_user_can(‘do_foo’))…

    But I’m curious, and not good enough with OO coding, to understand whether or not the named ‘Role’ is directly accessible through the API provided by the capabilities.php file.

    Thanks again.

    Rob

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I get the current user’s role?’ is closed to new replies.