WordPress.org

Ready to get started?Download WordPress

Forums

Problem with using admin_head in my plugin (3 posts)

  1. Devtard
    Member
    Posted 1 year ago #

    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.

  2. bcworkz
    Member
    Posted 1 year ago #

    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>");

  3. Devtard
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic