• Resolved Beee

    (@beee)


    How can I override this message ?

    Your account has been activated. You may now log in.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    One way is to create an English translation file. The other is to remove the TML action that adds this message, and use the same condition to add your own.

    Thread Starter Beee

    (@beee)

    That second one is what I’m looking for. Can you provide some insight which this is ?

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Well, this line shows us that the message is added using the tml_request action with a default priority of 10. So, the simplest way would be to apply a callback that runs after that one, removing TML’s message and adding your own as so:

    
    function tml_custom_action_messages( $tml ) {
        if ( isset( $_GET['activation'] ) && 'complete' == $_GET['activation'] ) {
            $tml->errors->remove( 'activation_complete' );
            $tml->errors->add( 'activation_complete', 'YOUR MESSAGE HERE' );
        }
    }
    add_action( 'tml_request', 'tml_custom_action_messages', 11 );
    
    Thread Starter Beee

    (@beee)

    AAH… It’s an ‘action message’. I tried hooking into template message, but that didn’t work out as expected.

    Will try this and report back.

    Thread Starter Beee

    (@beee)

    The message works, but it’s styled as an error (red border, red background). Which is expectable because it has the class ‘error’.

    Would it be an idea to remove the error but to add a template message ?

    Thread Starter Beee

    (@beee)

    That didn’t work out as expected ?? Adding the message works, but I get another message which I didn’t expect.

    See https://imgur.com/a/jAfrE.

    So I tweaked my login form a bit to not show the error message when activation is complete.

    Like this:

    <div class="tml tml-login" id="theme-my-login<?php $template->the_instance(); ?>">
        <?php $template->the_action_template_message( 'login' ); ?>
        <?php
            if ( isset( $_GET['activation'] ) && 'complete' == $_GET['activation'] ) {
                // do nothing
            } else {
                $template->the_errors();
            }
            // etc.
        ?>

    It does produce the result I want, but am I overlooking something if I remove the message there ?

    • This reply was modified 6 years, 9 months ago by Beee.
    Plugin Author Jeff Farthing

    (@jfarthing84)

    To get the proper color, add a third parameter of 'notice' to $tml->errors->add() method.

    Thread Starter Beee

    (@beee)

    Perfect. I added message and it did what I wanted it to do.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Override message for ‘action complete’’ is closed to new replies.