WordPress.org

Ready to get started?Download WordPress

Forums

How To show the text for administrator only ? (6 posts)

  1. manbritians
    Member
    Posted 2 years ago #

    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

  2. marv51
    Member
    Posted 2 years ago #

    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

  3. manbritians
    Member
    Posted 2 years ago #

    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!';
    }
    ?>

    ?

  4. marv51
    Member
    Posted 2 years ago #

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

    Hope this helps.

    Marvin

  5. manbritians
    Member
    Posted 2 years ago #

    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!';
    }
    ?>

    ?

  6. marv51
    Member
    Posted 2 years ago #

    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();
    } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.