a little script that improves the BP experience during a login error
- 
		This script replaces the default WP login scheme with my own customized for BuddyPress. Now if users enter the wrong username or password they won’t get sent to the non-buddypress wp-login.php page. Only lightly tested, but work ok. ` 
 // replacement for regular login – gets rif of wp-login.php page
 function bp_authenticate_username_password($user, $username, $password) {
 if ( is_a($user, ‘WP_User’) ) { return $user; }if ( empty($username) || empty($password) ) { 
 bp_core_add_message( __(‘ERROR: Empty Username field or empty Password field. See the sidebar for log in support.’, ‘scg’) , ‘error’ );
 wp_redirect(get_option(‘siteurl’));
 return false;
 }$userdata = get_userdatabylogin($username); if ( !$userdata ) { 
 bp_core_add_message( __(‘ERROR: Incorrect Username. See the sidebar for log in support.’, ‘scg’) , ‘error’ );
 wp_redirect(get_option(‘siteurl’));
 return false;
 }$userdata = apply_filters(‘wp_authenticate_user’, $userdata, $password); if ( is_wp_error($userdata) ) { 
 bp_core_add_message( __(‘ERROR: Invalid username or incorrect password.. See the sidebar for log in support.’, ‘scg’) , ‘error’ );
 wp_redirect(get_option(‘siteurl’));
 return false;
 }if ( !wp_check_password($password, $userdata->user_pass, $userdata->ID) ) { 
 bp_core_add_message( __(‘ERROR: Incorrect Password. See the sidebar for log in support.’, ‘scg’) , ‘error’ );
 wp_redirect(get_option(‘siteurl’));
 return false;
 }$user = new WP_User($userdata->ID); 
 return $user;
 }add_filter(‘authenticate’, ‘bp_authenticate_username_password’, 10, 3); 
 remove_filter(‘authenticate’, ‘wp_authenticate_username_password’, 20, 3);
 `
- The topic ‘a little script that improves the BP experience during a login error’ is closed to new replies.