Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Redirection Issue regarding activation (2 posts)

Started 6 months, 3 weeks ago by: ankurm

  • Profile picture of ankurm ankurm said 6 months, 3 weeks ago:

    hey,
    I created custom login and registration pages for my buddypress installation and now if a new user registers and tries to login without activating his/her account first, he/she gets redirected to the wordpress login.
    how can i redirect them to the custom login or registration page??

    thanks

  • Profile picture of ankurm ankurm said 6 months, 3 weeks ago:

    I found a way to accomplish it…
    Paste this piece of code in your theme functions file..

    // Stop user accounts logging in that have not been activated (user_status = 2)
    function bp_core_signup_disable_inactive_modified( $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 )
    		header("Location:".get_site_url()."/login?err=not-activated");   /*Your Custom Message*/
    	else
    		return $auth_obj;
    }
    add_filter( 'authenticate', 'bp_core_signup_disable_inactive_modified', 30, 2 );