bp_core_signup_disable_inactive

Display a "resend email" link when an unregistered user attempts to log in.

Description

(WP_User|WP_Error) bp_core_signup_disable_inactive( (constant) $user = null, (string) $username = '', (string) $password = '' ); 

Returns (WP_User|WP_Error)

Parameters (3)

0. $user — Optional. (constant) => null
Either the WP_User or the WP_Error object.
1. $username — Optional. (string) => ''
The inputted, attempted username.
2. $password — Optional. (string) => ''
The inputted, attempted password.

Usage

  1. if ( !function_exists( 'bp_core_signup_disable_inactive' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // Either the WP_User or the WP_Error object. 
  5. $user = null; 
  6.  
  7. // The inputted, attempted username. 
  8. $username = ''; 
  9.  
  10. // The inputted, attempted password. 
  11. $password = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_core_signup_disable_inactive($user, $username, $password); 
  15.  

Defined (1)

The function is defined in the following location(s).

/bp-members/bp-members-functions.php  
  1. function bp_core_signup_disable_inactive( $user = null, $username = '', $password ='' ) { 
  2. // Login form not used. 
  3. if ( empty( $username ) && empty( $password ) ) { 
  4. return $user; 
  5.  
  6. // An existing WP_User with a user_status of 2 is either a legacy 
  7. // signup, or is a user created for backward compatibility. See 
  8. // {@link bp_core_signup_user()} for more details. 
  9. if ( is_a( $user, 'WP_User' ) && 2 == $user->user_status ) { 
  10. $user_login = $user->user_login; 
  11.  
  12. // If no WP_User is found corresponding to the username, this 
  13. // is a potential signup. 
  14. } elseif ( is_wp_error( $user ) && 'invalid_username' == $user->get_error_code() ) { 
  15. $user_login = $username; 
  16.  
  17. // This is an activated user, so bail. 
  18. } else { 
  19. return $user; 
  20.  
  21. // Look for the unactivated signup corresponding to the login name. 
  22. $signup = BP_Signup::get( array( 'user_login' => sanitize_user( $user_login ) ) ); 
  23.  
  24. // No signup or more than one, something is wrong. Let's bail. 
  25. if ( empty( $signup['signups'][0] ) || $signup['total'] > 1 ) { 
  26. return $user; 
  27.  
  28. // Unactivated user account found! 
  29. // Set up the feedback message. 
  30. $signup_id = $signup['signups'][0]->signup_id; 
  31.  
  32. $resend_url_params = array( 
  33. 'action' => 'bp-resend-activation',  
  34. 'id' => $signup_id,  
  35. ); 
  36.  
  37. $resend_url = wp_nonce_url( 
  38. add_query_arg( $resend_url_params, wp_login_url() ),  
  39. 'bp-resend-activation' 
  40. ); 
  41.  
  42. $resend_string = '<br /><br />' . sprintf( __( 'If you have not received an email yet, <a href="%s">click here to resend it</a>.', buddypress ), esc_url( $resend_url ) ); 
  43.  
  44. return new WP_Error( 'bp_account_not_activated', __( '<strong>ERROR</strong>: Your account has not been activated. Check your email for the activation link.', buddypress ) . $resend_string );