It’s been quite a while since I posted anything on this blog. Have been really busy doing development work for others and could not devote time to blogging.

I have a quick snippet to share, which is most commonly used while programming in WordPress. The following code snippet let’s you check if the current user logged in is an Administrator or no.

function dm_is_admin(){
	return current_user_can( 'manage_options' );

Paste the above code inside functions.php of the active theme. Please note that I have used the function name as dm_is_admin, since is_admin function for WordPress already exists. However, the built-in is_admin function only checks if you are currently on the WordPress Dashboard or no.

You can use this code snippet to display certain information in the front end only when the Admin is logged in. I use this to display debugging information on any live site, this comes very handy.

Hope this is going to help you, as well!
Stay Digified!!
Sachin Khosla

Share this post: