Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter landonwb

    (@landonwb)

    I got this working. It was a major pain.

    define('DB_NAME', 'my_database');
    define('DB_USER', 'username');
    define('DB_PASSWORD', 'password');
    define('DB_HOST', 'localhost'); 
    
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');
    $table_prefix  = 'wp_';
    // Define absolute path to where
    // your blog is located
    define('ABSPATH',
    '/home/website_root/public_html/wordpress_directory/');
    
    require_once(ABSPATH.'wp-settings.php');
    define('WPINC', 'wp-includes');
    
    	require('https://www.your_domain/raceblog/wp-config.php');
    require_once( ABSPATH . WPINC . '/wp-db.php');
    require_once( ABSPATH . WPINC . '/cache.php');
    require_once( ABSPATH . WPINC . '/registration.php');
    require_once( ABSPATH . WPINC . '/formatting.php');
    require_once( ABSPATH . WPINC . '/plugin.php');
    require_once( ABSPATH . WPINC . '/user.php');
    require_once( ABSPATH . WPINC . '/functions.php');
    require_once( ABSPATH . WPINC . '/pluggable.php');
    
    function my_wp_login($username,$password)
    {
    	$user_login = '';
    	$user_pass = '';
    	$using_cookie = FALSE;
    
    	if ( !isset( $_REQUEST['redirect_to'] ) || is_user_logged_in() )
    $redirect_to = 'wp-admin/';
    else
    $redirect_to = $_REQUEST['redirect_to'];
    
    if ( true ) {
    	$user_login = $username;
    	$user_login = sanitize_user( $user_login );
    	$user_pass  = $password;
    			$rememberme = false;
    } else {
    	$cookie_login = wp_get_cookie_login();
    	if ( ! empty($cookie_login) ) {
    		$using_cookie = true;
    		$user_login = $cookie_login['login'];
    		$user_pass = $cookie_login['password'];
    	}
    }
    
    do_action_ref_array('wp_authenticate', array(&$user_login, &$user_pass));
    
    if ( $user_login && $user_pass && empty( $errors ) ) {
    	$user = new WP_User(0, $user_login);
    
    // If the user can't edit posts,
    // send them to their profile.
    
    if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
    
    //$redirect_to = get_option('siteurl') . '/wp-admin/profile.php';
    
    if ( wp_login($user_login, $user_pass, $using_cookie) ) {
    if ( !$using_cookie )
    					wp_setcookie($user_login, $user_pass, false, '', '', $rememberme);
    				do_action('wp_login', $user_login);
    				   //wp_redirect($redirect_to);
    			//exit();
    		} else {
    			if ( $using_cookie )
    					$errors['expiredsession'] = __('Your session has expired.');
    		}
    	}
    }
    
    // Create WordPress user
    wp_create_user($username, $password, $email );		
    
    // Login to WordPress
    my_wp_login($username,$password);
Viewing 1 replies (of 1 total)