Skip to:
Content
Pages
Categories
Search
Top
Bottom

WordPress user roles broken


  • HBDev
    Participant

    @harryberry94

    Hello I have a website which relies on user roles such as administrator to show certain content. I have installed BBPress which seems to break my user roles for example all Administrators become Keymasters also which is fine but if I run a query such as the code below it evaluates to false.

    Any help would be greatly appreciated.

    
    <?php
             if (is_user_logged_in() ) { 
    
             $user_ID = get_current_user_id();
             $user_info = get_userdata($user_ID);
             if(isset($user_info->roles) && implode(', ', $user_info->roles) == 'administrator') { ?>;
             <?php } >;
Viewing 1 replies (of 1 total)

  • Pascal Casier
    Moderator

    @casiepa

    Hi,

    Please put code into the <code> tags (have done it for you now) 🙂

    Try to visualize the outcome of implode(', ', $user_info->roles), because it will give you multiple values separated by a comma, so it will probably never give ‘administrator’.

    Pascal.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar