Support » Fixing WordPress » How To show the text for administrator only ?

  • manbritians

    (@manbritians)


    Hello

    I you want to show the text of each article in the last but I want this text does not appear, but the manager and I want does not appear for any visitor

    I would like you know what is the thing that I do to do that?

    To explain :

    I want to put text in the Code, but I want this text does not appear unless the Director of the blog entry is already registered

Viewing 5 replies - 1 through 5 (of 5 total)
  • marv51

    (@marv51)

    With http://codex.wordpress.org/Function_Reference/is_user_logged_in you could check if the user is logged in.

    And with http://codex.wordpress.org/Function_Reference/current_user_can you can check what privileges the user has.

    The two functions in an if statement around your text in the template file should solve your problem.

    Let me know if you have questions about this.

    Marvin

    manbritians

    (@manbritians)

    How do I add code html Instead of
    Welcome, registered user! in:
    <?php
    if ( is_user_logged_in() ) {
    echo ‘Welcome, registered user!’;
    } else {
    echo ‘Welcome, visitor!’;
    }
    ?>

    ?

    marv51

    (@marv51)

    <?php if ( is_user_logged_in() ) { ?>
    HTML here
    <?php } else { ?>
    other HTML here
    <?php } ?>

    Hope this helps.

    Marvin

    manbritians

    (@manbritians)

    please ho to add this is <?php if(function_exists(‘the_views’)) { the_views(); } ?> in this

    <?php
    if ( is_user_logged_in() ) {
    echo ‘Welcome, registered user!’;
    } else {
    echo ‘Welcome, visitor!’;
    }
    ?>

    ?

    marv51

    (@marv51)

    Depending on if you want the_views() for logged in users:

    <?php if (is_user_logged_in() && function_exists('the_views')) { the_views();
    } ?>

    If you want it only for logged out users:

    <?php if(!is_user_logged_in() && function_exists('the_views')) {
    the_views();
    } ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How To show the text for administrator only ?’ is closed to new replies.