I've got a script where people pay to access a membership site. After the transaction is completed, they are sent to a download page.
There aren't any downloads in this case -- the stuff is on a WordPress blog.
The trouble is that the payment script doesn't know about WordPress.
What I want is that when the download page comes up, it creates a new User record in WordPress if it doesn't already exist, then displays their login credentials; otherwise, it says it's already there and tells them how to login.
I wrote a little code that sits on the download page to create a new User record in WordPress. (The DL page is in a specific location and cannot be moved.)
The code on the DL page looks generally like this:
chdir(...); // goes to the folder where WP is installed
require_once( getcwd().'/wp-load.php' ); // <<---- weirdness here sometimes!
require_once( getcwd().'/wp-includes/registration.php' );
$the_pwd = ($pwd) ? $pwd : wp_generate_password( 12, false );
$the_uid = $cust_email;
$user_id = username_exists( $the_uid );
if ( !$user_id )
{
$user_id = wp_create_user( $the_uid, $the_pwd, $the_uid );
// display login info to the user
} else {
// the user record already exists
// tell how to login and request a pwd reset
}
Here's the thing... this code works exactly as I want it to ... but ONLY IF wordpress is installed in the document root.
When it's installed in a subfolder, the 2nd line above that includes wp-load.php either sends the browser a redirect somewhere else, or it just dies with no error or exception being raised. If I put echos in the code to trace progress, and if it doesn't redirect, they work fine until wp-load.php is included then the output just stops; an echo before it displays, and no echos after it appear.
wp-load.php tests some stuff and then includes wp-config.php.
wp-config.php sets a bunch of stuff then includes wp-settings.php.
I turned on the debug flag in wp-config.php, but it still doesn't show anything.
There's an error happening somewhere, but I can't tell where. Nothing is being written to the error_log file.
I need this to work when WP is installed in folders as well as in the document root.
Any suggestions?
(Basically, I just need to create a new WP User record somehow. This seemed like the easiest approach, but it's turning into a nighmare.)
Thanks
-David