bp_core_screen_activation

Handle the loading of the Activate screen.

Description

bp_core_screen_activation(); 

Usage

  1. if ( !function_exists( 'bp_core_screen_activation' ) ) { 
  2. require_once '/bp-members/bp-members-screens.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_core_screen_activation(); 
  7.  

Defined (1)

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

/bp-members/bp-members-screens.php  
  1. function bp_core_screen_activation() { 
  2.  
  3. // Bail if not viewing the activation page. 
  4. if ( ! bp_is_current_component( 'activate' ) ) { 
  5. return false; 
  6.  
  7. // If the user is already logged in, redirect away from here. 
  8. if ( is_user_logged_in() ) { 
  9.  
  10. // If activation page is also front page, set to members directory to 
  11. // avoid an infinite loop. Otherwise, set to root domain. 
  12. $redirect_to = bp_is_component_front_page( 'activate' ) 
  13. ? bp_get_members_directory_permalink() 
  14. : bp_get_root_domain(); 
  15.  
  16. // Trailing slash it, as we expect these URL's to be. 
  17. $redirect_to = trailingslashit( $redirect_to ); 
  18.  
  19. /** 
  20. * Filters the URL to redirect logged in users to when visiting activation page. 
  21. * @since 1.9.0 
  22. * @param string $redirect_to URL to redirect user to. 
  23. */ 
  24. $redirect_to = apply_filters( 'bp_loggedin_activate_page_redirect_to', $redirect_to ); 
  25.  
  26. // Redirect away from the activation page. 
  27. bp_core_redirect( $redirect_to ); 
  28.  
  29. // Grab the key (the old way). 
  30. $key = isset( $_GET['key'] ) ? $_GET['key'] : ''; 
  31.  
  32. // Grab the key (the new way). 
  33. if ( empty( $key ) ) { 
  34. $key = bp_current_action(); 
  35.  
  36. // Get BuddyPress. 
  37. $bp = buddypress(); 
  38.  
  39. // We've got a key; let's attempt to activate the signup. 
  40. if ( ! empty( $key ) ) { 
  41.  
  42. /** 
  43. * Filters the activation signup. 
  44. * @since 1.1.0 
  45. * @param bool|int $value Value returned by activation. 
  46. * Integer on success, boolean on failure. 
  47. */ 
  48. $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) ); 
  49.  
  50. // If there were errors, add a message and redirect. 
  51. if ( ! empty( $user->errors ) ) { 
  52. bp_core_add_message( $user->get_error_message(), 'error' ); 
  53. bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) ); 
  54.  
  55. bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) ); 
  56. $bp->activation_complete = true; 
  57.  
  58. /** 
  59. * Filters the template to load for the Member activation page screen. 
  60. * @since 1.1.1 
  61. * @param string $value Path to the Member activation template to load. 
  62. */ 
  63. bp_core_load_template( apply_filters( 'bp_core_template_activate', array( 'activate', 'registration/activate' ) ) );