bb_upgrade_1020

The BuddyPress bb upgrade 1020 function.

Description

bb_upgrade_1020(); 

Usage

  1. if ( !function_exists( 'bb_upgrade_1020' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-admin/includes/functions.bb-upgrade.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bb_upgrade_1020(); 
  7.  

Defined (1)

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

/bp-forums/bbpress/bb-admin/includes/functions.bb-upgrade.php  
  1. function bb_upgrade_1020() { 
  2. if ( ( $dbv = bb_get_option_from_db( 'bb_db_version' ) ) && $dbv >= 977 ) 
  3. return; 
  4.  
  5. global $bbdb; 
  6.  
  7. $users = $bbdb->get_results( "SELECT ID, user_login, user_nicename FROM $bbdb->users WHERE user_nicename IS NULL OR user_nicename = ''" ); 
  8.  
  9. if ( $users ) { 
  10. foreach ( $users as $user ) { 
  11. $user_nicename = $_user_nicename = bb_user_nicename_sanitize( $user->user_login ); 
  12. while ( is_numeric($user_nicename) || $existing_user = bb_get_user_by_nicename( $user_nicename ) ) 
  13. $user_nicename = bb_slug_increment($_user_nicename, $existing_user->user_nicename, 50); 
  14.  
  15. $bbdb->query( "UPDATE $bbdb->users SET user_nicename = '$user_nicename' WHERE ID = $user->ID;" ); 
  16.  
  17. bb_update_option( 'bb_db_version', 977 ); 
  18.  
  19. return 'Done adding nice-names to existing users: ' . __FUNCTION__;