WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 3 months ago

#25793 new defect (bug)

In a multisite, get_site_option() doesn't work in login_redirect filter

Reported by: sgissinger Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.6.1
Component: Options, Meta APIs Keywords: reporter-feedback close
Focuses: multisite Cc:

Description

The following code fails :

function dessange_login_redirect($redirect_to, $request, $user)
{
    return get_site_option(OPT_SITE_URL);
}
add_filter('login_redirect', 'dessange_login_redirect', 1, 3);

unless I connect $wpdb manually before calling get_site_option(), like in the following code

function dessange_login_redirect($redirect_to, $request, $user)
{
    global $wpdb;
    $wpdb->db_connect();

    return get_site_option(OPT_SITE_URL);
}
add_filter('login_redirect', 'dessange_login_redirect', 1, 3);

Change History (2)

comment:1 jeremyfelt4 months ago

  • Keywords reporter-feedback close added

I'm not able to reproduce an issue in current trunk.

  1. Insert a row to wp_sitemeta for testdomain as http://src.wordpress-develop/fake/login/redirect
  2. Add this code to mu-plugins/index.php
    define( 'OPT_SITE_URL', 'testdomain' );
    function dessange_login_redirect($redirect_to, $request, $user) {
    	return get_site_option( OPT_SITE_URL );
    }
    add_filter( 'login_redirect', 'dessange_login_redirect', 1, 3 );
    
  3. Login with form at http://src.wordpress-develop.dev/wp-login.php
  4. Login redirects to http://src.wordpress-develop/fake/login/redirect as expected.

Can you provide more detail on what fails?

comment:2 jeremyfelt3 months ago

  • Component changed from Multisite to Options and Meta
  • Focuses multisite added
Note: See TracTickets for help on using tickets.