• Most people find it hard to make a theme that actualy checks if the visiter is a member or visiter. Most people thinks it’s is_user_logged_in but it’s not.

    Instead add this code to your functions.php

    <?php function user_regvis_message() {
    get_currentuserinfo() ;
    global $user_level;
    if ($user_level > 0) {
     echo "Wellcome visiter"
    } else {
     echo "Wellcome Member"
    }
    }; ?>

    then add this in any location of your theme
    <?php user_regvis_message(); ?>
    Quick note; if your including tags do not use echo instead just place the code the fuction dose if for you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Most people thinks it’s is_user_logged_in but it’s not.

    Are you sure about that? For instance, the WordPress core uses is_user_logged_in to decide if a user is prompted with “Log in” or “Log out” prompt when a template uses the wp_loginout() tag.

    This is not correct: first of all the Visitor and Member greeting are mixed up. Secondly: a subscriber has user level 0.

    get_currentuserinfo() ;
      global $user_level;
      if ($user_level > 0) {
        echo "Welcome Contributor (or higher)"
      } else {
        echo "Welcome Visitor or Subscriber"
      }

    I agree with MichaelH: stick to is_user_logged_in

    The above described function could be useful to see if someone is more then just an anonymous subscriber (aka a contributor of higher). I use this to allow people to disable ads when they contribute by writing articles (posts).

    global $userdata;
        get_currentuserinfo();
        if ($userdata->user_level > 0) {
          if(function_exists('get_cimyFieldValue')) {
            $value = get_cimyFieldValue($userdata->ID, 'FIELDNAME');
            if ($value == 'YES') { $ads = 'off'; }
          }
        }

    I’ve tried playing with these and can’t get them to do what I want

    In essence, what I’m trying to do is with the top of the sidebar, I want (plain language coding) –

    if (is_home()) OR if not a user
    ~ do this ~
    then
    ~ this ~ (if user or not)

    I can get it to work with the is_home command() on it’s own, and I can get it to work with the !is_user_logged_in() on its own, but when I try to run the || (or) php in the middle of them I get a T_syntax (OR) php error and the sidebar fails to load.

    It’s starting to drive me nuts because I want the condition to simply be –
    If it’s the home page or it’s not a logged-in user (on any page or post), then show the sign up form

    Why is this so difficult?

    Can anyone help this grump old geezer?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Tutorial: how to check if user is logged in or a visitor’ is closed to new replies.