0

I can check whether a user has a given capability or not with user_can() function, but how can I check what capability a certain action requires?

For example, I'm using WP Job Manager plugin, this plugin introduce a new set of capabilities including edit_job_listings. Now a certain user tries to submit the edit job listing form, but he does not have this specific capability.

Now how can I hook into this action (i.e. submiting editing job form) and see what capabilitie(s) this action require in order to be performed successfully. If I can get the answer to this question I can compare it with user_can() result and can proceed accordingly with wp_die() or something else.

3
  • You can't really. You'd need to look at the source code of the plugin to know for certain. – Jacob Peattie Sep 20 '18 at 1:07
  • Then what would be the best way to proceed in this case? Currently, I'm doing something like this !current_user_can('edit_job_listings') && !empty($_POST['submit_job']) ? wp_die(...) : 'proceed with request'. But I thought there would be a better way. – Faisal Khurshid Sep 20 '18 at 1:14
  • You need to look at the plugin source or documentation for which capabilities are used. If you're still not sure you should ask the plugin author. – Jacob Peattie Sep 20 '18 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.