• If a contributor submit a post for review (from wp-admin/post-new.php), it shows “Draft Saved. View Preview”.

    I don’t think it’s quite relevant. I want to show a message, something like:

    Your post has been submitted successfully. Thank you.

    How can I achieve this? And if the message stay until the contributor clicks on cross icon, it would be nice.

    Thank you.

    • This topic was modified 2 years, 6 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    “Draft Saved” is a translatable string, so it can be changed to anything else through the “gettext” filter. The callback you add to the filter needs to watch for that specific string, and only change it if the current user’s role is contributor.

    “View Preview” should also be translatable, but I’ve not found it in the language files. IMO it ought to remain as-is anyway, even if you alter the other string.

    Thread Starter Morshed Alam

    (@sumon1068)

    Thank you @bcworkz for the reply.

    I’m using following code with no luck. Can you say what’s wrong?

    add_action('new_to_pending', 'amar_submit_notice');
    add_action('auto-draft_to_pending', 'amar_submit_notice');
    add_action('draft_to_pending', 'amar_submit_notice');
    function amar_submit_notice() {
        add_filter( 'gettext', 'change_submit_pending_notice');
    }
    function change_submit_pending_notice( $text ) {
        $text = str_ireplace( 'Draft Saved.',  'Your post has been submitted.',  $text );
        return $text;
    }
    Moderator bcworkz

    (@bcworkz)

    It looks like REACT based code like the block editor uses a different mechanism to translate strings separate from the PHP “gettext” filter. For example, using the string 'Post draft updated.' in your code works as expected in the classic editor.

    There is a “Draft Saved” string in the normal gettext translation file used by PHP, but the “Draft saved.” string (note subtle differences) actually used by the block editor occurs in a translation .json file which doesn’t involve the PHP “gettext” filter.

    There’s an equivalent mechanism within the REACT code, but sadly I don’t know much about how it works. The string has to occur somewhere in the script, so there has to be a way to override it, it’s the nature of JavaScript. I just don’t know exactly how to accomplish it.

    Sorry to mislead you about a solution. In my defense it does work for PHP based strings ??

    Thread Starter Morshed Alam

    (@sumon1068)

    Thanks for your time. I would like to left the thread open hoping someone might come with a solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Confirmation message when submitting post for review’ is closed to new replies.