[wp-hackers] checking roles in a plugin?

John Blackbourn johnbillion+wp at gmail.com
Fri Sep 7 04:05:32 GMT 2007


Sure you're echoing the variable out? (There's no echo in your code
snippet, that's all, and sometimes it's the simplist things...).

On 9/7/07, Keith Constable <kccricket at gmail.com> wrote:
> 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
> http://kccricket.net/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list