Subject: PHP

Allow only user administrator within plugin

It you want to restrict some code in your plugin within WP Admin only for “administrator”, you can’t just use “current_user_can()” as this function is defined after running plugin code. You need to execute your code only when “current_user_can()” is available: