• I want to make it so users who are contributors see certain information, but users who are subscribers do not see the information. In other words, I want the text to be conditional based on the logged-in user.

    I can do this with styles, showing and hiding based on conditions. For example:


    <?php
    if ( current_user_can('contributor') ) {

    echo '<style>';
    echo '.internal {display:normal;}';
    echo '</style>';
    }

    elseif (current_user_can('subscriber')) {

    echo '<style>';
    echo '.internal {display:none;}';
    echo '</style>';
    }

    ?>

    However, if you look in the source, a subscriber can still see the hidden text.

    How do I remove code from even being processed server side?

Viewing 1 replies (of 1 total)
  • What stops you from using the conditional statements around the content you want to display, instead of using it to display CSS changes only?

    I.e. use the current_user_can calls around the dynamic content that you need to display accordingly.

Viewing 1 replies (of 1 total)
  • The topic ‘hide text from users of a certain role’ is closed to new replies.