WordPress.org

Support

Support » Plugins and Hacks » Hacks » Calling Javascript after new post

Calling Javascript after new post

  • <?php
     function trigger_alert() {
     	echo '<script language="Javascript">alert("Your entry has been submitted. You may have to wait for an Editor to approve it.")</script>';
     }
     function some_post_actions( $post_ID )  {
       $friends = 'email@gmail.com';
       wp_mail( $friends, "Site updated", 'The blog site has been updated. Please check for a new entry.' );
    
     }?><?php add_action('admin_enqueue_scripts', 'trigger_alert');
    return $post_ID;?>

    So thats what I have. The emailing of the designated user works fine but I simply cannot get the Javascript alert to be called successfully.

    Any pointers would be gratefully received 🙂

    Kev.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Please note, I screwed that code up. It should be:

    <?php
     function trigger_alert() {
     	echo '<script language="Javascript">alert("Your entry has been submitted. You may have to wait for an Editor to approve it.")</script>';
     }
     function some_post_actions( $post_ID )  {
       $friends = 'email@gmail.com';
       wp_mail( $friends, "Site updated", 'The blog site has been updated. Please check for a new entry.' );
       add_action('admin_enqueue_scripts', 'trigger_alert');
       return $post_ID;?>
     }?>

    Just to add insult to injury, I screwed that up too. I should have this as the last line:

    <?php add_action('draft_to_publish', 'some_post_actions');?>

    Thanks for sticking with me 😉

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Calling Javascript after new post’ is closed to new replies.
Skip to toolbar