That would not work, not with the same name. Actions and filters are actually different forms of the same thing, so you can’t give them the same names, because both would trigger on either.
Actions are just a subset of filters, basically.
Also, that is far too late in the process to be attempting to enforce things like strong passwords or display names or what have you. When wp_insert_user is called, then a user really has to be inserted. If you want to enforce a rule, then you should catch it at the point where the data is collected and you have a chance to return it back to the interface, to tell the user that the rule is not satisfied.
Thread Starter
stokim
(@stokim)
@otto42 Thank you so much for your reply.
You’re right, I agree with you that it would be better to enforce a rule at the point of data collected.
However, if we run Buddypress with a theme, they add and edit member’s password, display name, and email address separately. If we enforce strong password, limited display name, and limited email domain on register and settings, we have to add rules separately on theme’s function and plugin’s function.
If WordPress has an action filter at the first of line,
do_action('wp_pre_insert_user', $data);
We can just add rules with WP_Error class once.
Like above, wp_update_user,
do_action('wp_pre_update_user', $data);
In terms of consistency, we don’t need to consider the way of theme and plugins.
Thank you for your consideration again and have a wonderful day 😀
P.S. Thank you for letting me know the concept of filters. That sort of tips helps a lot for me 🙂
Best regards,
Jen
-
This reply was modified 6 years, 1 month ago by
stokim.
-
This reply was modified 6 years, 1 month ago by
stokim.
-
This reply was modified 6 years, 1 month ago by
stokim.