Put simply, I'm trying to redirect the user after clicking a 'Save Changes' button. The plugin uses custom capabilities, and so I want to check the current user has the correct capabilities before progressing with the save and redirect afterwards.
However, bit of a dilemma. I have tried loading the function that carries out what is mentioned above using 'admin_init' and 'admin_menu'.
Using 'admin_init', throws an undefined function error for the 'current_user_can' function, which makes sense since it hasn't been loaded yet (and is well documented in other help topics). The redirect works fine (using wp_safe_redirect).
On the other hand, using 'admin_menu' allows the 'current_user_can' function to work, but the redirect doesn't. This is because the headers have already been sent.
Is there a way to have both functions working in either actions 'admin_init' or 'admin_menu'?
Thanks in advance.