Changeset 1485935
- Timestamp:
- 08/29/2016 09:14:23 PM (10 years ago)
- Location:
- custom-add-user/trunk
- Files:
-
- 2 edited
-
README.txt (modified) (3 diffs)
-
custom-add-user.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-add-user/trunk/README.txt
r1444394 r1485935 5 5 Tags: custom, user, new, existing, add, promote, single, form, skip, invitation, shibboleth, ldap, activate, invite, expire, multisite, admin 6 6 Requires at least: 3.0.1 7 Tested up to: 4. 5.38 Stable tag: 2.0. 17 Tested up to: 4.6 8 Stable tag: 2.0.2 9 9 License: GPLv3 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 71 71 72 72 == Changelog == 73 74 = 2.0.2 = 75 * Fix - Adding an existing user should not throw out the errror "Sorry, username already exists." 76 73 77 = 2.0.1 = 74 78 * Bug fixes … … 112 116 113 117 == Upgrade Notice == 118 114 119 = 2.0.0 = 115 120 * A lot has changed. Please check the changelog. -
custom-add-user/trunk/custom-add-user.php
r1443942 r1485935 15 15 * Author URI: http://sanghviharshit.com 16 16 * License: GPL3 17 * Version: 2.0. 117 * Version: 2.0.2 18 18 */ 19 19 … … 214 214 /* Check if user already exists in the network */ 215 215 $user_details = null; 216 $user_email = wp_unslash( $_REQUEST['email'] ); 217 if ( false !== strpos( $user_email, '@' ) ) { 218 $user_details = get_user_by( 'email', $user_email ); 219 } else { 220 if ( is_super_admin() ) { 221 $user_details = get_user_by( 'login', $user_email ); 222 } else { 223 wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) ); 224 die(); 225 } 226 } 227 216 217 /* Find user by user_login instead of email */ 218 $user_login = wp_unslash( $_REQUEST['user_login'] ); 219 //$user_email = wp_unslash( $_REQUEST['email'] ); 220 $user_details = get_user_by( 'login', $user_login ); 221 228 222 if ( !$user_details ) { 223 if ( ! current_user_can( 'create_users' ) ) { 224 wp_die( 225 '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . 226 '<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>', 227 403 228 ); 229 } 229 230 // Adding a new user to this site 230 231 $new_user_email = wp_unslash( $_REQUEST['email'] ); … … 241 242 wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) ); 242 243 $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $_REQUEST[ 'email' ] ) ); 243 wpmu_activate_signup( $key ); 244 $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); 245 wp_redirect( $redirect ); 244 $new_user = wpmu_activate_signup( $key ); 245 if ( is_wp_error( $new_user ) ) { 246 $redirect = add_query_arg( array( 'update' => 'addnoconfirmation' ), 'user-new.php' ); 247 } else { 248 $redirect = add_query_arg( array( 'update' => 'addnoconfirmation', 'user_id' => $new_user['user_id'] ), 'user-new.php' ); 249 } 250 wp_redirect( $redirect ); 246 251 die(); 247 252 } 248 253 } else { 249 //Add existing user to the blog. 254 if ( ! current_user_can( 'promote_user', $user_details->ID ) ) { 255 wp_die( 256 '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . 257 '<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>', 258 403 259 ); 260 } 261 //Adding an existing user to this blog 250 262 $new_user_email = $user_details->user_email; 251 263 $redirect = 'user-new.php';
Note: See TracChangeset
for help on using the changeset viewer.