[wp-hackers] checking roles in a plugin?

Mindshare Studios info at mindsharestudios.com
Fri Sep 7 06:20:33 GMT 2007


Hi again, 

Here's an even more concise example of my issue, when I activate this plugin
all bets are off - blank white screen. Why would this be killing WP?

<?php
/*
Plugin Name:poop
*/

if ( current_user_can('edit_posts') ) {
	//stuff
}

?>

Damian

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Keith
Constable
Sent: Thursday, September 06, 2007 8:47 PM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] checking roles in a plugin?

Mindshare Studios wrote:
> Hi -
> 
> How can you do a simple role check within a plugin before echoing some
> content to the screen?
> 
> I'm trying to do something like this:
> 
> if (current_user_can('edit_posts')) {
> 	$var = 'sweet!';
> }
> 
> But that isn't working at all. Any ideas?


Well, that's how you do it.  Are you testing it as the administrator?
If not, are you absolutely sure that the user you're testing it as has
the edit_posts capability?  Refer to Roles_and_Capabilities [1] on the
Codex to be sure.

[1] http://codex.wordpress.org/Roles_and_Capabilities

-Keith Constable



More information about the wp-hackers mailing list