Title: Problem with using admin_head in my plugin
Last modified: August 20, 2016

---

# Problem with using admin_head in my plugin

 *  [Devtard](https://wordpress.org/support/users/devtard/)
 * (@devtard)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/problem-with-using-admin_head-in-my-plugin/)
 * I need to put a HTML code (meta redirect) to the <head> section in my WP admin
   after a user submits a form and certain conditions are met. Unfortunately it 
   seems that using add_action(‘admin_head’, ‘my_custom_admin_head’); doesn’t work
   if I put it in the function used for printing my options page.
 * If it is anywhere else, it works, but then I would have to add an option to a
   database and constantly check it for changes to determine if the script is allowed
   put the redirect code to <head>.
 * Isn’t there a way to achieve this in a simpler way?
    When I just use header()
   or wp_redirect() I get the “headers already sent” error.
 * Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/problem-with-using-admin_head-in-my-plugin/#post-3196648)
 * Are you able to output inline javascript as part of the form submit’s target?
   `
   if ($myConditions == $formData) printf("<script>location.href='RedirectTarget.
   html'</script>");`
 *  Thread Starter [Devtard](https://wordpress.org/support/users/devtard/)
 * (@devtard)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/problem-with-using-admin_head-in-my-plugin/#post-3196649)
 * Yes, that works. But isn’t there a way to do it via PHP?
 * I don’t really like JavaScript, but if there is no other solution I will consider
   using it.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem with using admin_head in my plugin’ is closed to new replies.

## Tags

 * [headers already sent](https://wordpress.org/support/topic-tag/headers-already-sent/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [Devtard](https://wordpress.org/support/users/devtard/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/problem-with-using-admin_head-in-my-plugin/#post-3196649)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
