• Installed the welcome-visitor plugin. When I go to options->Welcome I get an error msg indicating not authorized. I found on the plugin blog some fix to the code. The fix says to remove the following check:

    global $user_level;
    if ($user_level < 8)
    die($no_access_msg);

    $user_level is null. To fix, I could comment out but I’d rather convert it to the new capabilities/roles.

    So how do I check for admin authority? I’ve been reviewing the capabilities.php file and am just not very familiar with the oops nomenclature. I tried this: $role = get_role(‘administrator’); but can’t seem to reference the var? An associative array is returned? When I echo I get resource #3 so I know I’m not referencing it properly.

    All I need is a couple lines of code to determine whether user is admin… Thanks to all.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Off the cuff code, but should at least point you in the right direction:

    global		$user_ID;
    
    $isAdmin	= 0;
    $meta		= get_usermeta($user_ID, 'wp_capabilities');
    
    if (is_array($meta) && $meta['wp_capabilities']) {
    	$capa	= unserialize($meta['wp_capabilities']);
    	if ($capa['administrator']) {
    		$isAdmin	= 1;
    	}
    }
    Thread Starter j8h9

    (@j8h9)

    Outstanding. Thank you for speedy response. I’m beginning to love wordpress.

    howbowers

    (@howbowers)

    You can fix this without altering any code.

    1. Go to the Users page
    2. Select your user ID
    3. In “Update Selected” area, click “Set the Role of checked users to” and select “Administrator” from the pop-up menu
    4. Click the “Bulk Upadate” button.

    This also fixed my problem with the Related Posts plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Welcome Visitor plugin fails userlevel test’ is closed to new replies.