BP_Admin_Setting_tab::settings_save_lagecy()

Description

Source

File: bp-core/classes/class-bp-admin-setting-tab.php

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
protected function settings_save_lagecy() {
    global $wp_settings_fields;
 
    $fields = isset( $wp_settings_fields[ $this->tab_name ] )? (array) $wp_settings_fields[ $this->tab_name ] : [];
    $legacy_names = [];
 
    foreach( $fields as $section => $settings ) {
        foreach( $settings as $setting_name => $setting ) {
            $legacy_names[] = $setting_name;
        }
    }
 
    // Some legacy options are not registered with the Settings API, or are reversed in the UI.
    $legacy_options = array(
        'bp-enable-private-network',
        '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',
    );
 
    $legacy_options = array_intersect( $legacy_options, $legacy_names );
 
    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 );
    }
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.