Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/28/2019 11:10:31 PM (5 years ago)
Author:
imath
Message:

Make sure custom visibility is disabled for the default profile field

props venutius

Fixes #8042

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-update.php

    r11233 r12390  
    269269            bp_update_to_2_7();
    270270        }
     271
     272        // Version 5.0.0.
     273        if ( $raw_db_version < 12385 ) {
     274            bp_update_to_5_0();
     275        }
    271276    }
    272277
     
    541546    // Do not ignore deprecated code for existing installs.
    542547    bp_add_option( '_bp_ignore_deprecated_code', false );
     548}
     549
     550/**
     551 * 5.0.0 update routine.
     552 *
     553 * - Make sure the custom visibility is disabled for the default profile field.
     554 *
     555 * @since 5.0.0
     556 */
     557function bp_update_to_5_0() {
     558    /**
     559     * The xProfile component is active by default on new installs, even if it
     560     * might be inactive during this update, we need to set the custom visibility
     561     * for the default field, in case the Administrator decides to reactivate it.
     562     */
     563    global $wpdb;
     564    $bp_prefix = bp_core_get_table_prefix();
     565    $field_id  = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE name = %s", addslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) );
     566
     567    $wpdb->insert(
     568        $bp_prefix . 'bp_xprofile_meta',
     569        array(
     570            'object_id'   => $field_id,
     571            'object_type' => 'field',
     572            'meta_key'    => 'allow_custom_visibility',
     573            'meta_value'  => 'disabled'
     574        ),
     575        array(
     576            '%d',
     577            '%s',
     578            '%s',
     579            '%s'
     580        )
     581    );
    543582}
    544583
Note: See TracChangeset for help on using the changeset viewer.