I'm working on an autologin for Wordpress and everything was working really good, till I enabled my multisite and tried to use it when multisite is off it does its thing logs in and redirects to dashboard, but when I enable it trows
"Error establishing Database Connection"
What could be causing this?
Does multisite WordPress change the database URL?
Here is the code for you to see.
include'../wordpress/wp-load.php';
$errors = array();
$username = 'admin';
$password = '123456';
$remember = "true";
$login_data = array();
$login_data['user_login'] = $username;
$login_data['user_password'] = $password;
$login_data['remember'] = $remember;
$user_verify = wp_signon($login_data, true);
wp_set_auth_cookie($user_verify->ID);
wp_redirect(admin_url());
exit;
Well after looking it up i realized two things
1: the error came from wp-load.php
2: as i thought it was because the file was taking current url as database url
so in fixed it doing this
Go to > wp-includes/ms-load.php
Look for ms_load_current_site_and_network() function and just afther the function starts set the $path variable to your url this way
since my wordpress install was a local one
my url was localhost/wordpress
the system already gets "localhost" the rest of my url is "wordpress"
so path must contain "wordpress"
the function now looks like this
then i run my login.php file and it worked!!!
hope it helps