I have set up a registration form in my theme for free users to sign up with that works great. I have a second type of free subscriber that I want to add a custom capability and custom registration field to their registration form (a second custom form specifically for them).
This second type of user is one where a corporation has licensed the site to their members and has paid in bulk. Therefore the user needs a free level with a custom cap of "view" and a registration field of "Licensee" with a value of "Big Corp".
I've been struggling to get this working and have tried several methods from the forum with no luck. Here's a bit of the form I'm using that works for free subscribers.
- Code: Select all
/* Load registration file. */
require_once( ABSPATH . WPINC . '/registration.php' );
/* Check if users can register. */
$registration = get_option( 'users_can_register' );
/* If user registered, input info. */
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'adduser' ) {
$userdata = array(
'user_pass' => esc_attr( $_POST['pass1'] ),
'user_login' => esc_attr( $_POST['user-name'] ),
'user_email' => esc_attr( $_POST['email'] ),
'first_name' => esc_attr( $_POST['first-name'] ),
'last_name' => esc_attr( $_POST['last-name'] ),
'role' => get_option( 'default_role' ),
);
if ( ($_POST['user-name'] ) && ( $_POST['email'] ) && ( $_POST['pass1'] ) && ( $_POST['pass1'] == $_POST['pass2'] ) ) {
$new_user = wp_insert_user( $userdata );
}
Any tips on how to add the custom field and value and the custom capability when the form is submitted? I want these to be hidden from the new user. Any help would be greatly appreciated.