Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In wp-admin/includes/update-core.php we find the following line:

add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' );

I want to remove this action, so I created a mu plugin with the following content:

<?php # -*- coding: utf-8 -*-
add_action( '_core_updated_successfully', 't5_no_redirect_after_update', 0 );

function t5_no_redirect_after_update()
{
    remove_action( '_core_updated_successfully', '_redirect_to_about_wordpress' );
}

It does … nothing. I am still redirected. Tested with single site and multi site installations.

I guess I miss something obvious, as usual. :)
How to do it better?

Update

Based on Brady’s answer I build a very minimal version:

<?php # -*- coding: utf-8 -*-
/* Plugin Name: T5 No redirect after core upgrade. */
add_action( '_core_updated_successfully', 't5_no_redirect_after_update', 0 );

function t5_no_redirect_after_update()
{
    show_message( __('WordPress updated successfully') );

    // Include admin-footer.php and exit
    include(ABSPATH . 'wp-admin/admin-footer.php');

    exit;
}

Now we see the success message and no other action is called. You can download the plugin on GitHub. Use it as regular plugin or as MU plugin.

share|improve this question
    
The _core_updated_successfully mentioned by @Brady action seems missing from 3.8.* ( >3.7 ?? ). Any ideas of a a replacement ? –  krembo99 Feb 19 at 4:11
    
@krembo99 It is still there: /wp-admin/includes/update-core.php at the end of the file. –  toscho Feb 19 at 6:52
    
yep.. my bad. Was looking at a custom core install . –  krembo99 Feb 19 at 7:34

1 Answer 1

up vote 5 down vote accepted

Don't remove the action but add your own before it. If you remove the action you will never get the message saying it was upgraded successfully. Here you can provide your own info on what to do next.

function tp_dont_redirect_to_about_wordpress( $new_version ) {
    global $wp_version, $pagenow, $action;

    if ( version_compare( $wp_version, '3.4-RC1', '>=' ) )
        return;

    // Ensure we only run this on the update-core.php page. wp_update_core() could be called in other contexts.
    if ( 'update-core.php' != $pagenow )
        return;

    if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action )
        return;

    // Load the updated default text localization domain for new strings
    load_default_textdomain();

    // See do_core_upgrade()
    show_message( __('WordPress updated successfully') );
    show_message( '<span>' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $new_version, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
    echo '</div>';

    // Include admin-footer.php and exit
    include(ABSPATH . 'wp-admin/admin-footer.php');
    exit();
}
add_action( '_core_updated_successfully', 'tp_dont_redirect_to_about_wordpress', 1, 1 );

I know in chat you showed that you had difficulty removing the action so I set about looking for a solution that doesn't remove the action but adds one before it.

The above code is a copy of the core function it hooks on _core_updated_successfully but strips out the redirect and a few messages.

As you can see there is an exit(); at the end of the function so if you hook this function before the other then the exit should stop any further hooks from firing.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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