Support » Plugins » Redirect on publish_post action hook

  • I’m writing a plugin that integrates WP with another application… it’s nearly complete but I need one last little line of code worked out.

    I have an action hook on “publish_post” that runs some db lookups and some logic then it generates a url and I want it to open that url either in the current window or a new window (it doesn’t matter).

    using wp_redirect($url); doesn’t do anything

    neither does
    header("Location: $url");
    and neither does
    header("Refresh: 0;url=$url");

    the only thing that will open my url in a new window is this:

    echo '<script type="text/javascript">\''.$url.'\')</script>';

    doing that will open my page in a new window, but the current page (the WP post editor) will crash with the following message:

    Warning: Cannot modify header information – headers already sent by (output started at
    /serverurl/wp-content/plugins/wp_smf_commenter/wp_smf_commenter.php:73) in
    /serverurl/wp-includes/pluggable.php on line 275

    where serverurl is the complete path on my server and wp_smf_commenter is the name of my plugin.
    line 73 is the javascript line above.

    I really really really don’t want to use javascript. Does anyone have any suggestions?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirect on publish_post action hook’ is closed to new replies.