Support » Fixing WordPress » alert message for publishing post successfully

  • Hi ,

    I need to display popup or alert box when user publishes the post successfully

    kindly help me. thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Please check this hooks for the attach Success message when post is published
    add_action( 'draft_to_publish', 'your_functions_name', 10, 1 );

    add_action( 'publish_post', 'your_functions_name', 10, 2 );

    Other hook for the attach Success message when post is saved.
    add_action( 'save_post', 'your_functions_name' );

    Thread Starter Abhishek26

    (@abhishek26)

    what to wirte in function, i just want alert success! message

    Thread Starter Abhishek26

    (@abhishek26)

    function on_post_publish( $strOldStatus, $strNewStatus, $post) {
    // A function to perform actions when a post is published.
    if( ( $strOldStatus === ‘draft’ || $strOldStatus === ‘auto-draft’ ) && $strNewStatus === ‘publish’ ) {
    echo ‘<script type=”text/javascript”>alert(“Success!!”);</script>’;
    }

    }

    i tried this but no use, please let me know wrong in this code

    Hi, you can try with the POST data when you publish or update the post.
    For example:
    In functions.php, please do type below code and do action on posts like update or create a new post.

    print_r($_POST);

    In this POST data, you will find the condition that will match your criteria like current action, post_publish_type or any other unique action you can use to put the conditional logic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘alert message for publishing post successfully’ is closed to new replies.