Featured Post

Debrand your W960 / P1 for FREE (or your P990, M600, W950)

After my successful debrand your phone for about a £5 (33,618 hits, 104 comments) and then unbrand your mobile for free (11,680 hits, 161 comments) posts. I now bring you the easiest way to de-brand your phone for free. No more looking for files in folders which are about 41 bytes, no more trying to...

Read More

Hide from all except admin

Posted by Ryan Cullen | Posted in Plugins | Posted on 9th November 2007

0

I wanted to put a WP-Admin link on my blog, but one which only showed to me whilst I was logged in.
So hunting through the WordPress Codex I tried to find something like is_admin(), but couldn’t find it. Then going through all the PHP files I found this function current_user_can(capability) which returns true or false if the logged in user can do that capability. Next I had to work out a capability which only admin could do, but a quick look at the source code showed that it should be possible to enter an integer which related to a level.
So finally I have this on my blog:
<?php if(current_user_can(10)) { ?><a href="/wp-admin/">WP-Admin</a><?php } ?>


Write a comment

Do you agree to the T&Cs?