[buddypress-trac] [BuddyPress] #2772: Error message for attempted login when user is not yet activated

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Tue Nov 30 16:36:07 UTC 2010


#2772: Error message for attempted login when user is not yet activated
----------------------------+-----------------------------------------------
 Reporter:  detrate         |       Owner:     
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  1.3
Component:  Core            |     Version:     
 Keywords:  error messages  |  
----------------------------+-----------------------------------------------
 I was confused as a developer as to why I couldn't login as a user.  I
 realized (thanks boonebgorges) that it's because I hadn't activated the
 users yet.

 I know this seems obvious in hindsight but the major issue I faced in
 troubleshooting this, was a lack of an error message.

 If I, as a developer was confused, I can only imagine what my users would
 think.

 workaround, add the following to bp-custom.php:

 {{{
 remove_filter( 'authenticate', 'bp_core_signup_disable_inactive' );
 add_filter( 'authenticate', 'bp_core_signup_disable_inactive_with_error',
 11, 2);

 function bp_core_signup_disable_inactive_with_error( $auth_obj, $username
 ) {
         global $bp, $wpdb;

         if ( !$user_id = bp_core_get_userid( $username ) )
                 return $auth_obj;

         $user_status = (int) $wpdb->get_var( $wpdb->prepare( "SELECT
 user_status FROM $wpdb->users WHERE ID = %d", $user_id ) );

         if ( 2 == $user_status ) {
                 bp_core_add_message( 'It looks like you have not activated
 your account yet.' );
                 bp_core_redirect( $bp->root_domain );
         } else {
                 return $auth_obj;
         }
 }

 function bbg_add_template_notice_to_header() {
         if ( !is_user_logged_in() )
                 do_action( 'template_notices' );
 }
 add_action( 'bp_before_container', 'bbg_add_template_notice_to_header' );
 }}}

-- 
Ticket URL: <http://trac.buddypress.org/ticket/2772>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list