1. Home
  2. Wordpress
  3. Check if admin

This snippet checks if the logged in user has admin permissions and executes code if true.

#wordpress#php
if( current_user_can( 'administrator' ) ){
   // do something
}
copy
Full Wordpress cheatsheet