bp_core_admin_settings_save()
Save our settings.
Description Description
Source Source
File: bp-core/admin/bp-core-admin-settings.php
function bp_core_admin_settings_save() {
global $wp_settings_fields;
if ( isset( $_GET['page'] ) && 'bp-settings' == $_GET['page'] && !empty( $_POST['submit'] ) ) {
check_admin_referer( 'buddypress-options' );
// Because many settings are saved with checkboxes, and thus will have no values
// in the $_POST array when unchecked, we loop through the registered settings.
if ( isset( $wp_settings_fields['buddypress'] ) ) {
foreach( (array) $wp_settings_fields['buddypress'] as $section => $settings ) {
foreach( $settings as $setting_name => $setting ) {
$value = isset( $_POST[$setting_name] ) ? $_POST[$setting_name] : '';
bp_update_option( $setting_name, $value );
}
}
}
// Some legacy options are not registered with the Settings API, or are reversed in the UI.
$legacy_options = array(
'bp-disable-account-deletion',
'bp-disable-avatar-uploads',
'bp-disable-cover-image-uploads',
'bp-disable-group-avatar-uploads',
'bp-disable-group-cover-image-uploads',
'bp_disable_blogforum_comments',
'bp-disable-profile-sync',
'bp_restrict_group_creation',
'hide-loggedout-adminbar',
);
foreach( $legacy_options as $legacy_option ) {
// Note: Each of these options is represented by its opposite in the UI
// Ie, the Profile Syncing option reads "Enable Sync", so when it's checked,
// the corresponding option should be unset.
$value = isset( $_POST[$legacy_option] ) ? '' : 1;
bp_update_option( $legacy_option, $value );
}
bp_core_redirect( add_query_arg( array( 'page' => 'bp-settings', 'updated' => 'true' ), bp_get_admin_url( 'admin.php' ) ) );
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.6.0 | Introduced. |