• Resolved steveraven

    (@steveraven)


    Hi,

    Seeing as there are no logs recorded for redirections, I decided I’d have a play with the email settings as mentioned in the FAQ.

    So I set up the emails as per the code in there:

    // Do something after a redirection
    add_action('wp404arsp/after_redirect', 'my_404_after_redirect');
    function my_404_after_redirect($query){
    
        // Developers: Print $query array for more request context
    
        // Send me an e-mail
        wp_mail(
            '[email protected]', 
            'WP 404 Auto Redirect: New redirection', 
            'Hi! New redirection from ' . $args['request']['url'] . ' to ' . $query['redirection']['url'], 
            array('Content-Type: text/html; charset=UTF-8')
        );
    
        return;
    }

    …and swapped the ‘myemail’ bit for my own email address.

    On getting a few site-links completely wrong (for testing purposes), all I received in the email was:

    Hi! New redirection from to

    …so I’m obviously missing something.

    What is it that I’m missing?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello!

    Oops, looks like there’s a typo error in the “email after redirection example”. As the filter function suggest, you should use $query['request']['url'] instead of $args['request']['url'].

    If you want to check all data available in the $query, you should print it (it’s a big array, use some function like print_r()).

    Hope it helps!

    PS: I’ll fix the readme example.

    Regards.

    Thread Starter steveraven

    (@steveraven)

    Still not working I’m afraid.

    The FIRST query works – ie you can see what’s been added to the url after the website name, but the second part of the ‘query?!?’ still comes up as blank – that is you cannot see where exactly the user has been redirected to.

    I’d got some idea of using this method instead of the clunky and messy logs which you said that you didn’t want to add.

    This I think would be an excellent alternative, and it would also prove that the plugin was redirecting to the correct url- a little like the ‘test and preview’ bit in the main settings.

    • This reply was modified 5 years, 5 months ago by steveraven.
    • This reply was modified 5 years, 5 months ago by steveraven.
    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    For the second variable, use: $query['redirect']['url'].

    I updated the readme example with the good variable names. If you want to see all informations available in $query, use print_r($query).

    Regards.

    Thread Starter steveraven

    (@steveraven)

    Wonderful, works perfectly now!

    Loving how pre-redirected urls from wp-content/plugins/google-analytics-dashboard-some-random-css-blah-blah-blah goes to a post about sploshing!

    All the other redirected links thus far are visibly working fine now, and I think this little piece of extra info should convince any non-believers that this plugin works as advertised.

    • This reply was modified 5 years, 5 months ago by steveraven.
    • This reply was modified 5 years, 5 months ago by steveraven.
    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Yeah!

    I will think about a native solution for the redirection logging, but right now I’m pretty busy with an another plugin so I don’t much time :\

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sending Emails on Redirections’ is closed to new replies.