bp_core_admin_settings_save

Save our settings.

Description

bp_core_admin_settings_save(); 

Usage

  1. if ( !function_exists( 'bp_core_admin_settings_save' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/admin/bp-core-admin-settings.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_core_admin_settings_save(); 
  7.  

Defined (1)

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

/bp-core/admin/bp-core-admin-settings.php  
  1. function bp_core_admin_settings_save() { 
  2. global $wp_settings_fields; 
  3.  
  4. if ( isset( $_GET['page'] ) && 'bp-settings' == $_GET['page'] && !empty( $_POST['submit'] ) ) { 
  5. check_admin_referer( 'buddypress-options' ); 
  6.  
  7. // Because many settings are saved with checkboxes, and thus will have no values 
  8. // in the $_POST array when unchecked, we loop through the registered settings. 
  9. if ( isset( $wp_settings_fields[buddypress] ) ) { 
  10. foreach( (array) $wp_settings_fields[buddypress] as $section => $settings ) { 
  11. foreach( $settings as $setting_name => $setting ) { 
  12. $value = isset( $_POST[$setting_name] ) ? $_POST[$setting_name] : ''; 
  13.  
  14. bp_update_option( $setting_name, $value ); 
  15.  
  16. // Some legacy options are not registered with the Settings API, or are reversed in the UI. 
  17. $legacy_options = array( 
  18. 'bp-disable-account-deletion',  
  19. 'bp-disable-avatar-uploads',  
  20. 'bp-disable-cover-image-uploads',  
  21. 'bp-disable-group-avatar-uploads',  
  22. 'bp-disable-group-cover-image-uploads',  
  23. 'bp-disable-profile-sync',  
  24. 'hide-loggedout-adminbar',  
  25. ); 
  26.  
  27. foreach( $legacy_options as $legacy_option ) { 
  28. // Note: Each of these options is represented by its opposite in the UI 
  29. // Ie, the Profile Syncing option reads "Enable Sync", so when it's checked,  
  30. // the corresponding option should be unset. 
  31. $value = isset( $_POST[$legacy_option] ) ? '' : 1; 
  32. bp_update_option( $legacy_option, $value ); 
  33.  
  34. bp_core_redirect( add_query_arg( array( 'page' => 'bp-settings', 'updated' => 'true' ), bp_get_admin_url( 'admin.php' ) ) );