Answer the question
In order to leave comments, you need to log in
Where can I find a normal WP description (add_action)?
The essence of the problem is simple, I found an example with add_action('admin_menu', 'mt_add_pages');
But this is only for the admin, but I need it for everyone, while each user category has its own.
The question is how it will look and even better, where can I find a list of all events in order to use it normally? As I understand it, each event = method or function in WP, it is thanks to this (their existence in this form) that you can cling to them and do something of your own additionally. But what is responsible for the formation of the menu in this case, in principle? I'm talking about the menu on the side ...
Answer the question
In order to leave comments, you need to log in
1. The admin_menu hook works in the admin panel (wp-admin), not for the admin. He is responsible for assembling the menu in the admin panel.
2. Work with restrictions on roles (administrator, regular user, etc.) is done using capabilities and roles checks.
3. All hooks can be found on hookr.io , in the WordPress documentation and, most importantly, in the source code of both the core itself and the plugins you use.
4. You understand in general correctly. Hooks are control points where you can connect and do something - either perform actions (action), modify data (filter). An important nuance is that many functions can be attached to one hook, each can be assigned its own priority. Also, don't forget that many hooks take parameters. Also, filters, for example, should always return data (return $x).
However, all this is in the documentation.
wp-kama.ru/function/add_action
developer.wordpress.org/reference/functions/add_action
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question