Getting admin notices working for plugin errors
What you need to do (as we discussed in comments) is run your conditional logic inside the function that that add_action calls. For example, you’re adding an action to the admin notices hook. The action will run, but the stuff inside that action’s callback will only run if you let it. add_action( ‘admin_notices’, ‘your_custom_function’ ); … Read more