WordPress: If admin or editor logged in

Last updated on

If user logged in and has admin rights

if (current_user_can('administrator')) { 
    echo "admin logged in";
}

If user logged in and has editor rights

if (current_user_can('editor')) { 
    echo "editor logged in";
}

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.

Leave a reply

Your email address will not be published.