WordPress.org

Forums

Calling Javascript after new post (3 posts)

  1. kevleitch
    Member
    Posted 3 years ago #

    <?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.

  2. kevleitch
    Member
    Posted 3 years ago #

    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;?>
     }?>
  3. kevleitch
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic