Creating a page to make new users…
-
So, I’m trying to create a page accessible by logged in users through which these users can create children accounts. From what I can tell, the register page is inaccessible to logged in users, so I can’t use them. I also don’t allow my users access to the wp-admin area, so I can’t use the “add new users” page of the wp-admin.
I’ve tried creating a function that accepts form input and uses bp_core_signup_user to no avail. It simply will not create the user, returning the standard “could not create account” error.
function my_user_creation( $email, $username, $password, $first_name, $last_name, $firm) { $new_user = bp_core_signup_user( $username, $password, $email, array() ); if( is_wp_error( $new_user ) ) { return $new_user; } $display_name = $first_name . ' ' . $last_name; update_user_meta( $new_user, 'nickname', $display_name ); update_user_meta( $new_user, 'first_name', $first_name ); update_user_meta( $new_user, 'last_name', $last_name ); if( bp_is_active( 'xprofile' ) ) xprofile_set_field_data( '1', $new_user, $display_name ); xprofile_set_field_data( '99', $new_user, $display_name ); xprofile_set_field_data( '145', $new_user, $firm ); xprofile_set_field_data( '360', $new_user, 'Agree' ); wp_cache_set( 'bp_user_fullname_' . $new_user, $display_name, 'bp' ); $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET display_name=%s, user_status=0 WHERE ID=%d", $display_name, $new_user ) ); bp_core_new_user_activity( $new_user ); wp_new_user_notification( $new_user ); return new WP_User( $new_user ); }
This is my function. Any tips or tricks that I’m overlooking? I can’t seem to find anything like this on google or the bp support pages. Thanks for your help in advanced.
- The topic ‘Creating a page to make new users…’ is closed to new replies.