0

I am working on a theme that display profiles I build a code according to theme - that it should display only limited profiles with the role queen and king.. I manage to open all the profile now the theme uses a themex.core.php file with all this information what to display and what not.. but I am really confused that this function

<?php
if ( is_user_logged_in() ) {
    $userr = new WP_User( $user_ID );
    if ( !empty( $userr->roles ) && is_array( $userr->roles ) ) {
        foreach ( $userr->roles as $rolee )
            $reguserr = $rolee;
    }
}
?>

is running normal on every page of the site but when I try to retrieve the value of $reguserr in the themex.core.php file I wasn't able to retrieve it what's going on can any body explain how I can get this work on those files ?

  • Please add what you expect the value of $reguserr to be, what the value of $reguserr is (including any errors with WP_DEBUG on), and how you're trying to output the $reguserr value. – mrwweb Sep 24 '14 at 0:51
0

You'r following an bad idea.

What you would like to reallize is, displaying a few profiles, not all. It doesn't matter if the role is named "king" or "queen" even if your specific roles called so.

There is an better way to reallize such Kind of requirements: Capabilities. Add an capabilitie to WordPress and just give that view roles you would like to Display that capabilitie. Then you are able to Change the Name of the role or define new "visible" roles without Messing arround with your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.