bp_core_update_group_fields_id_in_db()
On BuddyPress update
Description
Source
File: bp-core/compatibility/bp-incompatible-plugins-helper.php
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | function bp_core_update_group_fields_id_in_db() { if ( is_multisite() ) { global $wpdb ; $bp_prefix = bp_core_get_table_prefix(); $table_name = $bp_prefix . 'bp_xprofile_fields' ; if ( empty ( bp_xprofile_firstname_field_id( 0, false ) ) ) { //first name fields update $firstname = bp_get_option( 'bp-xprofile-firstname-field-name' ); $results = $wpdb ->get_results( "SELECT id FROM {$table_name} WHERE name = '{$firstname}'" ); $count = 0; if ( ! empty ( $results ) ) { foreach ( $results as $result ) { $id = absint( $result ->id ); if ( empty ( $count ) && ! empty ( $id ) ) { add_site_option( 'bp-xprofile-firstname-field-id' , $id ); $count ++; } else { $wpdb -> delete ( $table_name , array ( 'id' => $id ) ); } } } } if ( empty ( bp_xprofile_lastname_field_id( 0, false ) ) ) { //last name fields update $lastname = bp_get_option( 'bp-xprofile-lastname-field-name' ); $results = $wpdb ->get_results( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE name = '{$lastname}'" ); $count = 0; if ( ! empty ( $results ) ) { foreach ( $results as $result ) { $id = absint( $result ->id ); if ( empty ( $count ) && ! empty ( $id ) ) { add_site_option( 'bp-xprofile-lastname-field-id' , $id ); $count ++; } else { $wpdb -> delete ( $table_name , array ( 'id' => $id ) ); } } } } if ( empty ( bp_xprofile_nickname_field_id( true, false ) ) ) { //nick name fields update $nickname = bp_get_option( 'bp-xprofile-nickname-field-name' ); $results = $wpdb ->get_results( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE name = '{$nickname}'" ); $count = 0; if ( ! empty ( $results ) ) { foreach ( $results as $result ) { $id = absint( $result ->id ); if ( empty ( $count ) && ! empty ( $id ) ) { add_site_option( 'bp-xprofile-nickname-field-id' , $id ); $count ++; } else { $wpdb -> delete ( $table_name , array ( 'id' => $id ) ); } } } } add_site_option( 'bp-xprofile-field-ids-updated' , 1 ); } } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.9 | Introduced. |
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.