Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the workflow thought out:

  • User pays for something on your site using e-junkie.

  • After payment, a http post ( with user email and name gets sent to a wordpress registration script ) and registers that user automatically -- ignores if the email is in database

I think we can use the wp-register.php page for hacking! The problem I am having is having this run automatically.

I already have the option in e-junkie to send an http post after payment with (POST variables to use) automatically -- but now I am not sure how to do the WordPress registration part (automatically)

Post variables from e-junkie:

payer_email Buyer's email address
first_name Buyer's first name
last_name Buyer's last name

Thanks in advance!!

EDIT:

So, here is some code I came up with -- It works, but now I need it to send the username and password it generated to that email address automatically ?? Also the first and last name isn't recording ?? Thanks!!

require('wordpress/wp-blog-header.php');

$user_email = trim(isset($_POST['payer_email']) ? $_POST['payer_email'] : "");
$user_name = trim(isset($_POST['first_name']) ? $_POST['first_name'] : "");

$user_id = username_exists( $user_name );
if ( !$user_id ) {
    $random_password = wp_generate_password( 12, false );
    $user_id = wp_create_user( $user_name, $random_password, $user_email );
} else {
    $random_password = __('User already exists.  Password inherited.');
}
share|improve this question
add comment

1 Answer

How about using wp_create_user() and then add_user_meta()? Between those two, you should be able to store all the data you get back, and even store it in fields wordpress uses natively.

share|improve this answer
    
Great comment. So for code sake, how would you organize it with variables and such?? –  eberswine Jan 27 '12 at 23:06
    
Depends how the data comes in, but basically grab the payer_email and then MD5 hash (or something) that for the username. Randomly generate a password and run that all into wp_create_user() then put the first and last name in as usermeta (create_user will return the id of the created user)...you'll needa grub around in profile.php a bit and see what the usermeta name they're pulling for first and last name is, but that should be cake. –  m0r7if3r Jan 27 '12 at 23:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.