WordPress.org

Ready to get started?Download WordPress

Forums

Show div of content only if user is role 8 or higher (3 posts)

  1. Dennis
    Member
    Posted 1 year ago #

    Hello,
    I want to know if it's possible to make determinated content show only if the user of the post has and role higher then X.

    For example, make and div TEST in the single.php, if an "Author" post, it doesn't show. If an "Administrator" post, it show.

    Is that possible?
    Thanks

  2. Ravinder Kumar
    Member
    Posted 1 year ago #

    hi
    check this.gud luk.hope this will work for you
    also this

  3. Dennis
    Member
    Posted 1 year ago #

    I tried this two ways, didn' work:

    <?php
    global $userdata;
    get_currentuserinfo();
    if ( $user_info->ID == 1 )
    {
      echo 'User is an Author';
    }
    else
    {
      echo 'User is not an Author';
    }
    ?>

    and

    <?php
    $user = wp_get_current_user();
    if ($user->ID)
      if ( $user->ID == 1 )
        echo 'Admin';
      else
        echo 'Autor';
    ?>

    It only shows to first echo :/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags