Title: Calling Javascript after new post
Last modified: August 20, 2016

---

# Calling Javascript after new post

 *  [kevleitch](https://wordpress.org/support/users/kevleitch/)
 * (@kevleitch)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/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)

 *  Thread Starter [kevleitch](https://wordpress.org/support/users/kevleitch/)
 * (@kevleitch)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/calling-javascript-after-new-post/#post-2311054)
 * 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;?>
        }?>
       ```
   
 *  Thread Starter [kevleitch](https://wordpress.org/support/users/kevleitch/)
 * (@kevleitch)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/calling-javascript-after-new-post/#post-2311059)
 * 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.

## Tags

 * [add_action](https://wordpress.org/support/topic-tag/add_action/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 1 participant
 * Last reply from: [kevleitch](https://wordpress.org/support/users/kevleitch/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/calling-javascript-after-new-post/#post-2311059)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
