I am reposting. As my last questions wasn't famous.

My users are submitting custom post types (projects) from the frontend. How do I display notices (such as the one displayed on admin board) to the front end for when the user performs an action, example edit a post.

I know there are hooks for update/submit (post_updated_messages...) but those do not display anything on the frontend.

I tried putting the following but it doesn't work:


function alert_user()

function prepare_text(){
return 'You did it!';

in my theme I have


It doesn't work as prepare_text is never hooked to display_message!

Any help?


  • 5
    Next time, improve the existing question. Do not just ask the same question again. – fuxia Jul 9 '13 at 21:19
  • I did. But my question didn't get any interactions. Now, you can see. I've got an answer! – semyou Jul 10 '13 at 7:32

You could filter the_content:

add_action( 'post_updated', 'wpse105892_add_message', 10 );
function wpse105892_add_message() {
    add_filter( 'the_content', 'wpse105892_display_message' );

function wpse105892_display_message( $content ) {
    // remove the action once it's run
    remove_action( 'post_updated', 'wpse105892_add_message', 11 );

    $content = "<div class='your-message'>You did it!</div>\n\n" . $content;
    return $content;
  • I will try it and let you know! Thanks! Just curious, is there a reason why it would work on a core hook 'the_content' and not on my own hook. – semyou Jul 10 '13 at 18:32
  • If you've added a hook of your own that displays in the front end, then sure, you can hook it to that instead. I didn't see anything in your question about creating your own hook (is it display_message?). – Pat J Jul 10 '13 at 19:03
  • Yes. It is display_message! – semyou Jul 11 '13 at 13:44
  • Can you update your question to show how/where your display_message hook is created, please? – Pat J Jul 11 '13 at 14:07
  • Maybe this is my mistake. I use only add_action in the first function and then do_action (as seen above). Am I supposed to do anything else? – semyou Jul 11 '13 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.