It seems lately that I’m the only one ever to solve my problems … but if you find any of this useful, please let me know!
I was able to set up Premium registration by modifying the wp-login.php and registration.php files slightly.
In wp-login.php I had to copy the function “register_new_user” to define the function “register_premium_user.” From there, I changed:
$user_id = wp_create_user( $user_login, $user_pass, $user_email );
To
$capa='contributor';
$user_id = wp_create_user( $user_login, $user_pass, $user_email, $capa );
This sent the appropriate user level to the registration scripts. In order to call this function, though, I also had to copy the case “register” and create a new case “premregister.” Premium users can register by pointing to ‘wp-login.php?action=premregister’.
Next I had to change the line:
$errors = register_new_user($user_login, $user_email);
To
$errors = register_premium_user($user_login, $user_email);
And a little further down, I had to change:
<form name="registerform" id="registerform" action="wp-login.php?action=register" method="post">
To
<form name="registerform" id="registerform" action="wp-login.php?action=premregister" method="post">
Now we have premium users being directed to the correct registration page and being recognized as premium users. The final changes are in the registration.php file.
At the very bottom is the function “wp_create_user.” I had to change it a little bit to recognize my new value and send it on to the function “wp_insert_user” by changing this:
function wp_create_user($username, $password, $email = '') {
global $wpdb;
$user_login = $wpdb->escape($username);
$user_email = $wpdb->escape($email);
$user_pass = $password;
$userdata = compact('user_login', 'user_email', 'user_pass');
return wp_insert_user($userdata);
}
To this:
function wp_create_user($username, $password, $email = '', $capable = '') {
global $wpdb;
$user_login = $wpdb->escape($username);
$user_email = $wpdb->escape($email);
$user_pass = $password;
$role = $wpdb->escape($capable);
$userdata = compact('user_login', 'user_email', 'user_pass', 'role');
return wp_insert_user($userdata);
}
The empty ” after my $capable variable make it optional, so this addition won’t affect any other part of WP’s operation.
Unfortunately, WP only writes user roles on updates, not creation, so it takes one last bit of modification to make this all work. Scroll back up to the “wp_insert_user” function and change this:
if ( $update && isset($role) ) {
$user = new WP_User($user_id);
$user->set_role($role);
}
if ( !$update ) ) {
$user = new WP_User($user_id);
$user->set_role(get_option('default_role'));
}
To this:
if ( $update && isset($role) ) {
$user = new WP_User($user_id);
$user->set_role($role);
}
if ( !$update && isset($role) ) {
$user = new WP_User($user_id);
$user->set_role($role);
} else {
$user = new WP_User($user_id);
$user->set_role(get_option('default_role'));
}
Now, anyone who registers through wp-login.php?action=register will appear as a regular subscriber. Anyone who instead uses wp-login?action=premregister will appear as a contributor (merely for user level 1, it doesn’t matter what you call them so long as you stay consistent).
It took me 2 days to figure this out, let me know if it saves you some headache!