Skip to:
Content

BuddyPress.org

Changeset 12390


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

Make sure custom visibility is disabled for the default profile field

props venutius

Fixes #8042

Location:
trunk/src
Files:
3 edited

Legend:

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

    r11787 r12390  
    383383    if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) {
    384384        $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
     385
     386        // Make sure the custom visibility is disabled for the default field.
     387        if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_meta WHERE id = 1" ) ) {
     388            $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'allow_custom_visibility', 'disabled' );";
     389        }
    385390    }
    386391
  • 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
  • trunk/src/class-buddypress.php

    r12353 r12390  
    305305
    306306        $this->version    = '5.0.0-alpha';
    307         $this->db_version = 11105;
     307        $this->db_version = 12385;
    308308
    309309        /** Loading ***********************************************************/
Note: See TracChangeset for help on using the changeset viewer.