Ticket #6347: 6347.alt.2.patch
File 6347.alt.2.patch, 48.9 KB (added by , 4 years ago) |
---|
-
src/bp-core/admin/bp-core-admin-functions.php
diff --git src/bp-core/admin/bp-core-admin-functions.php src/bp-core/admin/bp-core-admin-functions.php index c9a5259e9..b81786427 100644
function bp_core_add_contextual_help_content( $tab = '' ) { 586 586 break; 587 587 588 588 case 'bp-profile-overview': 589 $retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.', 'buddypress' ) . '<br /><br />' . __( 'Note: Any fields in the first group will appear on the signup page.', 'buddypress' );589 $retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.', 'buddypress' ) . '<br /><br />' . __( 'Note: Drag fields from other groups and drop them on the "Signup Fields" tab to include them into your registration form.', 'buddypress' ); 590 590 break; 591 591 592 592 default: -
src/bp-core/admin/bp-core-admin-schema.php
diff --git src/bp-core/admin/bp-core-admin-schema.php src/bp-core/admin/bp-core-admin-schema.php index d7cab5bbe..7a10e39eb 100644
function bp_core_install_extended_profiles() { 389 389 // Make sure the custom visibility is disabled for the default field. 390 390 if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_meta WHERE id = 1" ) ) { 391 391 $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'allow_custom_visibility', 'disabled' );"; 392 $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'signup_position', 1 );"; 392 393 } 393 394 } 394 395 -
src/bp-core/bp-core-update.php
diff --git src/bp-core/bp-core-update.php src/bp-core/bp-core-update.php index a7791c445..7cb66c837 100644
function bp_update_to_5_0() { 598 598 * 8.0.0 update routine. 599 599 * 600 600 * - Edit the `new_avatar` activity type's component to `members`. 601 * - Upgrade Primary xProfile Group's fields to signup fields. 601 602 * 602 603 * @since 8.0.0 603 604 */ … … function bp_update_to_8_0() { 621 622 '%s', 622 623 ) 623 624 ); 625 626 if ( bp_get_signup_allowed() ) { 627 // Get the Primary Group's fields. 628 $signup_fields = $wpdb->get_col( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE group_id = 1 ORDER BY field_order ASC" ); 629 630 // Migrate potential signup fields. 631 if ( $signup_fields ) { 632 $signup_position = 0; 633 foreach ( $signup_fields as $signup_field_id ) { 634 $signup_position += 1; 635 636 $wpdb->insert( 637 $bp_prefix . 'bp_xprofile_meta', 638 array( 639 'object_id' => $signup_field_id, 640 'object_type' => 'field', 641 'meta_key' => 'signup_position', 642 'meta_value' => $signup_position, 643 ), 644 array( 645 '%d', 646 '%s', 647 '%s', 648 '%d', 649 ) 650 ); 651 } 652 } 653 } 624 654 } 625 655 626 656 /** -
src/bp-templates/bp-legacy/buddypress/members/register.php
diff --git src/bp-templates/bp-legacy/buddypress/members/register.php src/bp-templates/bp-legacy/buddypress/members/register.php index 4e8418e7f..d263470f2 100644
165 165 <h2><?php _e( 'Profile Details', 'buddypress' ); ?></h2> 166 166 167 167 <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> 168 <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>168 <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( bp_xprofile_signup_args() ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 169 169 170 170 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 171 171 -
src/bp-templates/bp-nouveau/buddypress/members/register.php
diff --git src/bp-templates/bp-nouveau/buddypress/members/register.php src/bp-templates/bp-nouveau/buddypress/members/register.php index 2c0a688f2..3a4fdfaac 100644
3 3 * BuddyPress - Members/Blogs Registration forms 4 4 * 5 5 * @since 3.0.0 6 * @version 4.0.06 * @version 8.0.0 7 7 */ 8 8 9 9 ?> … … 38 38 39 39 <?php /***** Extra Profile Details ******/ ?> 40 40 41 <?php if ( bp_is_active( 'xprofile' ) && bp_nouveau_ base_account_has_xprofile() ) : ?>41 <?php if ( bp_is_active( 'xprofile' ) && bp_nouveau_has_signup_xprofile_fields( true ) ) : ?> 42 42 43 43 <?php bp_nouveau_signup_hook( 'before', 'signup_profile' ); ?> 44 44 -
src/bp-templates/bp-nouveau/includes/template-tags.php
diff --git src/bp-templates/bp-nouveau/includes/template-tags.php src/bp-templates/bp-nouveau/includes/template-tags.php index 3439280fb..5ee755a05 100644
function bp_nouveau_container_classes() { 1515 1515 } 1516 1516 1517 1517 // Provide a class token to acknowledge additional extended profile fields added to default account reg screen 1518 if ( 'register' === bp_current_component() && bp_is_active( 'xprofile' ) && bp_nouveau_ base_account_has_xprofile()) {1518 if ( 'register' === bp_current_component() && bp_is_active( 'xprofile' ) && bp_nouveau_has_signup_xprofile_fields()) { 1519 1519 $classes[] = 'extended-default-reg'; 1520 1520 } 1521 1521 -
src/bp-templates/bp-nouveau/includes/xprofile/template-tags.php
diff --git src/bp-templates/bp-nouveau/includes/xprofile/template-tags.php src/bp-templates/bp-nouveau/includes/xprofile/template-tags.php index 26ef5199f..ba92bd40e 100644
3 3 * xProfile Template tags 4 4 * 5 5 * @since 3.0.0 6 * @version 3.0.06 * @version 8.0.0 7 7 */ 8 8 9 9 // Exit if accessed directly. … … function bp_nouveau_xprofile_edit_visibilty() { 62 62 * profile fields added to it for the registration screen. 63 63 * 64 64 * @since 3.0.0 65 * @deprecated 8.0.0 65 66 */ 66 67 function bp_nouveau_base_account_has_xprofile() { 67 return (bool) bp_has_profile( 68 array( 69 'profile_group_id' => 1, 70 'fetch_field_data' => false, 71 ) 72 ); 68 _deprecated_function( __FUNCTION__, '8.0.0', 'bp_nouveau_has_signup_xprofile_fields()' ); 69 return bp_nouveau_has_signup_xprofile_fields(); 70 } 71 72 /** 73 * Checks whether there are signup profile fields to display. 74 * 75 * @since 8.0.0 76 * 77 * @param bool Whether to init an xProfile loop. 78 * @return bool True if there are signup profile fields to display. False otherwise. 79 */ 80 function bp_nouveau_has_signup_xprofile_fields( $do_loop = false ) { 81 $signup_fields = (array) bp_xprofile_get_signup_field_ids(); 82 83 if ( ! $do_loop ) { 84 return 1 <= count( $signup_fields ); 85 } 86 87 return bp_has_profile( bp_xprofile_signup_args() ); 73 88 } -
src/bp-xprofile/admin/css/admin.css
diff --git src/bp-xprofile/admin/css/admin.css src/bp-xprofile/admin/css/admin.css index b84db929a..36d01b81c 100644
ul#field-group-tabs li.ui-state-active a.ui-tab { 62 62 color: #000; 63 63 } 64 64 65 li#signup-group a:focus { 66 box-shadow: none; 67 } 68 65 69 /* Toolbar */ 66 70 .tab-toolbar { 67 71 clear: left; -
src/bp-xprofile/admin/js/admin.js
diff --git src/bp-xprofile/admin/js/admin.js src/bp-xprofile/admin/js/admin.js index 99a5b4b5d..0773d6548 100644
function show_options( forWhat ) { 96 96 } 97 97 98 98 // Show/hides metaboxes according to selected field type supports. 99 jQuery( '#field-type-visibiliy-metabox, #field-type-required-metabox, #field-type-autolink-metabox, #field-type-member-types ' ).show();99 jQuery( '#field-type-visibiliy-metabox, #field-type-required-metabox, #field-type-autolink-metabox, #field-type-member-types, #field-signup-position-metabox' ).show(); 100 100 if ( -1 !== XProfileAdmin.hide_required_metabox.indexOf( forWhat ) ) { 101 101 jQuery( '#field-type-required-metabox' ).hide(); 102 102 } 103 103 104 if ( -1 !== XProfileAdmin.hide_signup_position_metabox.indexOf( forWhat ) ) { 105 jQuery( '#field-signup-position-metabox' ).hide(); 106 } 107 104 108 if ( -1 !== XProfileAdmin.hide_allow_custom_visibility_metabox.indexOf( forWhat ) ) { 105 109 jQuery( '#field-type-visibiliy-metabox' ).hide(); 106 110 } … … function titleHint( id ) { 207 211 } 208 212 209 213 jQuery( function() { 214 var isMovingToSignups = false; 210 215 211 216 // Set focus in Field Title, if we're on the right page. 212 217 jQuery( '#bp-xprofile-add-field #title' ).trigger( 'focus' ); … … jQuery( function() { 248 253 cursor: 'move', 249 254 axis: 'x', 250 255 opacity: 1, 251 items: 'li ',256 items: 'li:not(.not-sortable)', 252 257 tolerance: 'intersect', 253 258 254 259 update: function() { … … jQuery( function() { 270 275 tolerance: 'pointer', 271 276 272 277 update: function() { 278 if ( isMovingToSignups ) { 279 return false; 280 } 281 273 282 jQuery.post( ajaxurl, { 274 283 action: 'xprofile_reorder_fields', 275 284 'cookie': encodeURIComponent(document.cookie), … … jQuery( function() { 348 357 // When field is dropped on tab. 349 358 drop: function( ev, ui ) { 350 359 var $item = jQuery(this), // The tab 351 $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' ); // The tab body 360 $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' ), // The tab body 361 dropInGroup = function( fieldId ) { 362 var fieldOrder, postData = { 363 action: 'xprofile_reorder_fields', 364 'cookie': encodeURIComponent(document.cookie), 365 '_wpnonce_reorder_fields': jQuery( 'input#_wpnonce_reorder_fields' ).val(), 366 }; 367 368 // Select new tab as current. 369 $tabs.tabs( 'option', 'active', $tab_items.index( $item ) ); 370 371 // Refresh $list variable. 372 $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' ); 373 jQuery($list).find( 'p.nofields' ).hide( 'slow' ); 374 375 jQuery.extend( postData, { 376 'field_group_id': jQuery( $list ).attr( 'id' ), 377 'group_tab': jQuery( $item ).prop( 'id' ) 378 } ); 379 380 // Set serialized data 381 fieldOrder = jQuery( $list ).sortable( 'serialize' ); 382 383 if ( fieldId ) { 384 var serializedField = fieldId.replace( 'draggable_field_', 'draggable_signup_field[]=' ); 385 if ( fieldOrder ) { 386 fieldOrder += '&' + serializedField; 387 } else { 388 fieldOrder = serializedField; 389 } 390 391 jQuery.extend( postData, { 392 'new_signup_field_id': serializedField, 393 } ); 394 } else { 395 // Show new placement. 396 jQuery( this ).appendTo( $list ).show( 'slow' ).animate( { opacity: '1' }, 500 ); 397 398 // Refresh $list variable. 399 $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' ); 400 401 // Reset serialized data. 402 fieldOrder = jQuery( $list ).sortable( 'serialize' ); 403 404 jQuery.extend( postData, { 405 'field_group_id': jQuery( $list ).attr( 'id' ) 406 } ); 407 } 408 409 jQuery.extend( postData, { 410 'field_order': fieldOrder, 411 } ); 412 413 // Ajax update field locations and orders. 414 jQuery.post( ajaxurl, postData, function( response ) { 415 if ( response.data && response.data.signup_field ) { 416 jQuery( $list ).append( response.data.signup_field ); 417 418 if ( response.data.field_id ) { 419 jQuery( '#draggable_field_' + response.data.field_id + ' legend' ).append( 420 jQuery( '<span></span>' ).addClass( 'bp-signup-field-label' ).html( XProfileAdmin.signup_info ) 421 ); 422 } 423 } 424 }, 'json' ).always( function() { 425 isMovingToSignups = false; 426 } ); 427 }; 352 428 353 429 // Remove helper class. 354 430 jQuery($item).removeClass( 'drop-candidate' ); 355 431 356 // Hide field, change selected tab, and show new placement. 357 ui.draggable.hide( 'slow', function() { 358 359 // Select new tab as current. 360 $tabs.tabs( 'option', 'active', $tab_items.index( $item ) ); 361 362 // Show new placement. 363 jQuery(this).appendTo($list).show( 'slow' ).animate( {opacity: '1'}, 500 ); 364 365 // Refresh $list variable. 366 $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' ); 367 jQuery($list).find( 'p.nofields' ).hide( 'slow' ); 368 369 // Ajax update field locations and orders. 370 jQuery.post( ajaxurl, { 371 action: 'xprofile_reorder_fields', 372 'cookie': encodeURIComponent(document.cookie), 373 '_wpnonce_reorder_fields': jQuery( 'input#_wpnonce_reorder_fields' ).val(), 374 'field_order': jQuery( $list ).sortable( 'serialize' ), 375 'field_group_id': jQuery( $list ).attr( 'id' ) 376 }, 377 function() {} ); 378 }); 432 if ( 'signup-group' === jQuery( $item ).prop( 'id' ) ) { 433 // Simply add the field to signup ones. 434 dropInGroup( ui.draggable.prop( 'id' ) ); 435 436 } else if ( ! ui.draggable.prop( 'id' ).match( /draggable_signup_field_([0-9]+)/ ) ) { 437 // Hide field, change selected tab, and show new placement. 438 ui.draggable.hide( 'slow', dropInGroup ); 439 } 379 440 }, 380 441 over: function() { 442 isMovingToSignups = true; 381 443 jQuery(this).addClass( 'drop-candidate' ); 382 444 }, 383 445 out: function() { 384 446 jQuery(this).removeClass( 'drop-candidate' ); 447 isMovingToSignups = false; 385 448 } 386 449 }); 387 450 } 451 452 jQuery( '#signup-fields' ).on( 'click', '.removal', function( e ) { 453 e.preventDefault(); 454 455 var fieldId = jQuery( e.target ).attr( 'href' ).replace( '#remove_field-', '' ), 456 container = jQuery( e.target ).closest( '#draggable_signup_field_' + fieldId ); 457 458 if ( ! fieldId ) { 459 return false; 460 } 461 462 // Ajax update field locations and orders. 463 jQuery.post( ajaxurl, { 464 action: 'xprofile_remove_signup_field', 465 'cookie': encodeURIComponent(document.cookie), 466 '_wpnonce_reorder_fields': jQuery( 'input#_wpnonce_reorder_fields' ).val(), 467 'signup_field_id': fieldId 468 }, function( response ) { 469 if ( response.success ) { 470 jQuery( container ).remove(); 471 jQuery( '#draggable_field_' + fieldId + ' .bp-signup-field-label' ).remove(); 472 } 473 }, 'json' ); 474 } ); 388 475 }); -
src/bp-xprofile/bp-xprofile-admin.php
diff --git src/bp-xprofile/bp-xprofile-admin.php src/bp-xprofile/bp-xprofile-admin.php index 5bd8a899d..ed45fdd0f 100644
function xprofile_admin_screen( $message = '', $type = 'error' ) { 188 188 189 189 <?php endforeach; endif; ?> 190 190 191 <?php if ( bp_get_signup_allowed() ) : ?> 192 <li id="signup-group" class="not-sortable last"> 193 <a href="#tabs-signup-group" class="ui-tab"> 194 <?php esc_html_e( 'Signup Fields', 'buddypress' ); ?> 195 </a> 196 </li> 197 <?php endif; ?> 198 191 199 </ul> 192 200 193 201 <?php if ( !empty( $groups ) ) : foreach ( $groups as $group ) : … … function xprofile_admin_screen( $message = '', $type = 'error' ) { 294 302 295 303 </fieldset> 296 304 297 <?php if ( empty( $group->can_delete ) ) : ?>298 299 <p><?php esc_html_e( '* Fields in this group appear on the signup page.', 'buddypress' ); ?></p>300 301 <?php endif; ?>302 303 305 </div> 304 306 305 307 <?php endforeach; else : ?> … … function xprofile_admin_screen( $message = '', $type = 'error' ) { 309 311 310 312 <?php endif; ?> 311 313 314 <?php 315 // List fields to use into the signup form. 316 if ( bp_get_signup_allowed() ) { 317 $signup_groups = bp_xprofile_get_groups( 318 array( 319 'fetch_fields' => true, 320 'signup_fields_only' => true, 321 ) 322 ); 323 $has_signup_fields = false; 324 $signup_fields = array(); 325 $signup_fields_order = bp_xprofile_get_signup_field_ids(); 326 ?> 327 <div id="tabs-signup-group"" class="tab-wrapper"> 328 <div class="tab-toolbar"> 329 <p class="description"><?php esc_html_e( 'Drag fields from other groups and drop them on the above tab to include them into your registration form.', 'buddypress' ); ?></a> 330 </div> 331 <fieldset id="signup-fields" class="connectedSortable field-group" aria-live="polite" aria-atomic="true" aria-relevant="all"> 332 <legend class="screen-reader-text"> 333 <?php esc_html_e( 'Fields to use into the registration form', 'buddypress' );?> 334 </legend> 335 336 <?php 337 if ( ! empty( $signup_groups ) ) { 338 foreach ( $signup_groups as $signup_group ) { 339 if ( ! empty( $signup_group->fields ) ) { 340 $has_signup_fields = true; 341 342 foreach ( $signup_group->fields as $signup_field ) { 343 // Load the field. 344 $_signup_field = xprofile_get_field( $signup_field, null, false ); 345 346 /** 347 * This function handles the WYSIWYG profile field 348 * display for the xprofile admin setup screen. 349 */ 350 $signup_fields[ $_signup_field->id ] = bp_xprofile_admin_get_signup_field( $_signup_field, $signup_group, '' ); 351 } 352 } 353 } 354 355 // Output signup fields according to their signup position. 356 foreach ( $signup_fields_order as $ordered_signup_field_id ) { 357 if ( ! isset( $signup_fields[ $ordered_signup_field_id ] ) ) { 358 continue; 359 } 360 361 echo $signup_fields[ $ordered_signup_field_id ]; 362 } 363 } 364 365 if ( ! $has_signup_fields ) { 366 ?> 367 <p class="nodrag nofields"><?php esc_html_e( 'There are no registration fields set. The registration form uses the primary group by default.', 'buddypress' ); ?></p> 368 <?php 369 } 370 ?> 371 </fieldset> 372 373 <p><?php esc_html_e( '* Fields in this group appear on the registration page.', 'buddypress' ); ?></p> 374 </div> 375 <?php 376 } 377 ?> 312 378 </div> 313 379 </form> 314 380 </div> 315 316 381 <?php 317 382 } 318 383 … … function xprofile_admin_manage_field( $group_id, $field_id = null ) { 575 640 } 576 641 577 642 // Validate signup. 578 if ( ! empty( $_POST['signup-position'] ) ) { 579 bp_xprofile_update_field_meta( $field_id, 'signup_position', (int) $_POST['signup-position'] ); 580 } else { 581 bp_xprofile_delete_meta( $field_id, 'field', 'signup_position' ); 643 if ( $field->field_type_supports( 'signup_position' ) ) { 644 if ( ! empty( $_POST['signup-position'] ) ) { 645 bp_xprofile_update_field_meta( $field_id, 'signup_position', (int) $_POST['signup-position'] ); 646 } else { 647 bp_xprofile_delete_meta( $field_id, 'field', 'signup_position' ); 648 } 582 649 } 583 650 584 651 $do_autolink = ''; … … function xprofile_admin_delete_field_screen( $field_id, $field_type ) { 730 797 * Handles the ajax reordering of fields within a group. 731 798 * 732 799 * @since 1.0.0 800 * @since 8.0.0 Returns a JSON object. 733 801 */ 734 802 function xprofile_ajax_reorder_fields() { 735 736 803 // Check the nonce. 737 804 check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); 738 805 739 806 if ( empty( $_POST['field_order'] ) ) { 740 return false;807 return wp_send_json_error(); 741 808 } 742 809 743 parse_str( $_POST['field_order'], $order );744 745 810 $field_group_id = $_POST['field_group_id']; 811 $group_tab = ''; 812 813 if ( isset( $_POST['group_tab'] ) && $_POST['group_tab'] ) { 814 $group_tab = wp_unslash( $_POST['group_tab'] ); 815 } 816 817 if ( 'signup-fields' === $field_group_id ) { 818 parse_str( $_POST['field_order'], $order ); 819 $fields = (array) $order['draggable_signup_field']; 820 $fields = array_map( 'intval', $fields ); 821 822 if ( isset( $_POST['new_signup_field_id'] ) && $_POST['new_signup_field_id'] ) { 823 parse_str( $_POST['new_signup_field_id'], $signup_field ); 824 $signup_fields = (array) $signup_field['draggable_signup_field']; 825 } 826 827 // Adding a new field to the registration form. 828 if ( 'signup-group' === $group_tab ) { 829 $field_id = (int) reset( $signup_fields ); 830 831 // Load the field. 832 $field = xprofile_get_field( $field_id, null, false ); 833 834 if ( $field instanceof BP_XProfile_Field ) { 835 // The field doesn't support the feature, stop right away! 836 if ( ! $field->field_type_supports( 'signup_position' ) ) { 837 wp_send_json_error( 838 array( 839 'message' => __( 'This field cannot be inserted into the registration form.', 'buddypress' ), 840 ) 841 ); 842 } 843 844 $signup_position = bp_xprofile_get_meta( $field->id, 'field', 'signup_position' ); 845 846 if ( ! $signup_position ) { 847 $position = array_search( $field->id, $fields, true ); 848 if ( false !== $position ) { 849 $position += 1; 850 } else { 851 $position = 1; 852 } 853 854 // Set the signup position. 855 bp_xprofile_update_field_meta( $field->id, 'signup_position', $position ); 856 857 // Get the real Group object. 858 $group = xprofile_get_field_group( $field->id ); 859 860 // Gets the HTML Output of the signup field. 861 $signup_field = bp_xprofile_admin_get_signup_field( $field, $group ); 862 863 /** 864 * Fires once a signup field has been inserted. 865 * 866 * @since 8.0.0 867 */ 868 do_action( 'bp_xprofile_inserted_signup_field' ); 869 870 // Send the signup field to output. 871 wp_send_json_success( 872 array( 873 'signup_field' => $signup_field, 874 'field_id' => $field->id, 875 ) 876 ); 877 } else { 878 wp_send_json_error( 879 array( 880 'message' => __( 'This field has been already added to the registration form.', 'buddypress' ), 881 ) 882 ); 883 } 884 885 } else { 886 wp_send_json_error(); 887 } 888 } else { 889 // it's a sort operation. 890 foreach ( $fields as $position => $field_id ) { 891 bp_xprofile_update_field_meta( (int) $field_id, 'signup_position', (int) $position + 1 ); 892 } 746 893 747 foreach ( (array) $order['draggable_field'] as $position => $field_id ) { 748 xprofile_update_field_position( (int) $field_id, (int) $position, (int) $field_group_id ); 894 /** 895 * Fires once the signup fields have been reordered. 896 * 897 * @since 8.0.0 898 */ 899 do_action( 'bp_xprofile_reordered_signup_fields' ); 900 901 wp_send_json_success(); 902 } 903 } else { 904 /** 905 * @todo there's something going wrong here. 906 * moving a field to another tab when there's only the fullname field fails. 907 */ 908 parse_str( $_POST['field_order'], $order ); 909 $fields = (array) $order['draggable_field']; 910 911 foreach ( $fields as $position => $field_id ) { 912 xprofile_update_field_position( (int) $field_id, (int) $position, (int) $field_group_id ); 913 } 914 915 wp_send_json_success(); 749 916 } 750 917 } 751 918 add_action( 'wp_ajax_xprofile_reorder_fields', 'xprofile_ajax_reorder_fields' ); 752 919 920 /** 921 * Removes a field from signup fields. 922 * 923 * @since 8.0.0 924 */ 925 function bp_xprofile_ajax_remove_signup_field() { 926 // Check the nonce. 927 check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); 928 929 if ( ! isset( $_POST['signup_field_id'] ) || ! $_POST['signup_field_id'] ) { 930 return wp_send_json_error(); 931 } 932 933 $signup_field_id = (int) wp_unslash( $_POST['signup_field_id'] ); 934 935 // Validate the field ID. 936 $signup_position = bp_xprofile_get_meta( $signup_field_id, 'field', 'signup_position' ); 937 938 if ( ! $signup_position ) { 939 wp_send_json_error(); 940 } 941 942 bp_xprofile_delete_meta( $signup_field_id, 'field', 'signup_position' ); 943 944 /** 945 * Fires when a signup field is removed from the signup form. 946 * 947 * @since 8.0.0 948 */ 949 do_action( 'bp_xprofile_removed_signup_field' ); 950 951 wp_send_json_success(); 952 } 953 add_action( 'wp_ajax_xprofile_remove_signup_field', 'bp_xprofile_ajax_remove_signup_field' ); 954 753 955 /** 754 956 * Handles the reordering of field groups. 755 957 * … … add_action( 'wp_ajax_xprofile_reorder_groups', 'xprofile_ajax_reorder_field_grou 776 978 * Handles the WYSIWYG display of each profile field on the edit screen. 777 979 * 778 980 * @since 1.5.0 981 * @since 8.0.0 Adds the `$is_signup` parameter. 779 982 * 780 983 * @param BP_XProfile_Field $admin_field Admin field. 781 984 * @param object $admin_group Admin group object. 782 985 * @param string $class Classes to append to output. 986 * @param bool $is_signup Whether the admin field output is made inside the signup group. 783 987 */ 784 function xprofile_admin_field( $admin_field, $admin_group, $class = '' ) {988 function xprofile_admin_field( $admin_field, $admin_group, $class = '', $is_signup = false ) { 785 989 global $field; 786 990 787 $field = $admin_field; 991 $field = $admin_field; 992 $fieldset_id = sprintf( 'draggable_field_%d', $field->id ); 788 993 789 994 // Users admin URL. 790 995 $url = bp_get_admin_url( 'users.php' ); … … function xprofile_admin_field( $admin_field, $admin_group, $class = '' ) { 804 1009 'mode' => 'delete_field', 805 1010 'field_id' => (int) $field->id 806 1011 ), $url . '#tabs-' . (int) $field->group_id ); 807 } ?> 1012 } 1013 1014 // Avoid duplicate IDs into the signup group. 1015 if ( $is_signup ) { 1016 $fieldset_id = sprintf( 'draggable_signup_field_%d', $field->id ); 1017 } 1018 ?> 808 1019 809 <fieldset id=" draggable_field_<?php echo esc_attr( $field->id ); ?>" class="sortable<?php echo ' ' . $field->type; if ( !empty( $class ) ) echo ' ' . $class; ?>">1020 <fieldset id="<?php echo esc_attr( $fieldset_id ); ?>" class="sortable<?php echo ' ' . $field->type; if ( !empty( $class ) ) echo ' ' . $class; ?>"> 810 1021 <legend> 811 1022 <span> 812 1023 <?php bp_the_profile_field_name(); ?> 813 1024 814 <?php if ( empty( $field->can_delete ) 1025 <?php if ( empty( $field->can_delete ) ) : ?><?php esc_html_e( '(Primary)', 'buddypress' ); endif; ?> 815 1026 <?php bp_the_profile_field_required_label(); ?> 816 <?php if ( bp_xprofile_get_meta( $field->id, 'field', 'signup_position' ) ) : ?><?php esc_html_e( '(Sign-up)', 'buddypress' ); endif; ?> 1027 <?php if ( bp_get_signup_allowed() && $field->get_signup_position() ) : ?> 1028 <span class="bp-signup-field-label"><?php esc_html_e( '(Sign-up)', 'buddypress' );?></span> 1029 <?php endif; ?> 817 1030 <?php if ( bp_get_member_types() ) : echo $field->get_member_type_label(); endif; ?> 818 1031 819 1032 <?php … … function xprofile_admin_field( $admin_field, $admin_group, $class = '' ) { 859 1072 <div class="actions"> 860 1073 <a class="button edit" href="<?php echo esc_url( $field_edit_url ); ?>"><?php _ex( 'Edit', 'Edit field link', 'buddypress' ); ?></a> 861 1074 862 <?php if ( $field->can_delete ) : ?>1075 <?php if ( $field->can_delete && ! $is_signup ) : ?> 863 1076 864 1077 <div class="delete-button"> 865 1078 <a class="confirm submit-delete deletion" href="<?php echo esc_url( wp_nonce_url( $field_delete_url, 'bp_xprofile_delete_field-' . $field->id, 'bp_xprofile_delete_field' ) ); ?>"><?php _ex( 'Delete', 'Delete field link', 'buddypress' ); ?></a> … … function xprofile_admin_field( $admin_field, $admin_group, $class = '' ) { 867 1080 868 1081 <?php endif; ?> 869 1082 1083 <?php if ( $field->can_delete && $is_signup ) : ?> 1084 1085 <div class="delete-button"> 1086 <a class="submit-delete removal" href="<?php echo esc_attr( sprintf( '#remove_field-%d', $field->id ) ); ?>"><?php echo esc_html_x( 'Remove', 'Remove field link', 'buddypress' ); ?></a> 1087 </div> 1088 1089 <?php endif; ?> 1090 870 1091 <?php 871 1092 872 1093 /** … … function xprofile_admin_field( $admin_field, $admin_group, $class = '' ) { 882 1103 </div> 883 1104 </div> 884 1105 </fieldset> 885 886 1106 <?php 887 1107 } 888 1108 1109 /** 1110 * Handles the WYSIWYG display of signup profile fields on the edit screen. 1111 * 1112 * @since 8.0.0 1113 * 1114 * @param BP_XProfile_Field $signup_field The field to use into the signup form. 1115 * @param object $field_group The real field group object. 1116 * @param string $class Classes to append to output. 1117 * @param bool $echo Whether to return or display the HTML output. 1118 * @return string The HTML output. 1119 */ 1120 function bp_xprofile_admin_get_signup_field( $signup_field, $field_group = null, $class = '', $echo = false ) { 1121 add_filter( 'bp_get_the_profile_field_input_name', 'bp_get_the_profile_signup_field_input_name' ); 1122 1123 if ( ! $echo ) { 1124 // Set up an output buffer. 1125 ob_start(); 1126 xprofile_admin_field( $signup_field, $field_group, $class, true ); 1127 $output = ob_get_contents(); 1128 ob_end_clean(); 1129 } else { 1130 xprofile_admin_field( $signup_field, $field_group, $class, true ); 1131 } 1132 1133 remove_filter( 'bp_get_the_profile_field_input_name', 'bp_get_the_profile_signup_field_input_name' ); 1134 1135 if ( ! $echo ) { 1136 return $output; 1137 } 1138 } 1139 889 1140 /** 890 1141 * Print <option> elements containing the xprofile field types. 891 1142 * -
src/bp-xprofile/bp-xprofile-cache.php
diff --git src/bp-xprofile/bp-xprofile-cache.php src/bp-xprofile/bp-xprofile-cache.php index 5c5badae5..6881b7082 100644
function bp_xprofile_reset_user_mid_cache( $user_id ) { 314 314 wp_cache_delete( $user_id, 'bp_user_mid' ); 315 315 } 316 316 add_action( 'profile_update', 'bp_xprofile_reset_user_mid_cache', 10, 1 ); 317 318 /** 319 * Resets the signup field IDs cache. 320 * 321 * @since 8.0.0 322 */ 323 function bp_xprofile_reset_signup_field_cache() { 324 wp_cache_delete( 'signup_fields', 'bp_xprofile' ); 325 } 326 add_action( 'bp_xprofile_inserted_signup_field', 'bp_xprofile_reset_signup_field_cache' ); 327 add_action( 'bp_xprofile_reordered_signup_fields', 'bp_xprofile_reset_signup_field_cache' ); 328 add_action( 'bp_xprofile_removed_signup_field', 'bp_xprofile_reset_signup_field_cache' ); -
src/bp-xprofile/bp-xprofile-cssjs.php
diff --git src/bp-xprofile/bp-xprofile-cssjs.php src/bp-xprofile/bp-xprofile-cssjs.php index 94478187e..a92669499 100644
function xprofile_add_admin_js() { 57 57 'hide_allow_custom_visibility_metabox' => array(), 58 58 'hide_required_metabox' => array(), 59 59 'hide_member_types_metabox' => array(), 60 'hide_signup_position_metabox' => array(), 60 61 'text' => array( 61 62 'defaultValue' => __( 'Default Value', 'buddypress' ), 62 63 'deleteLabel' => __( 'Delete', 'buddypress' ), 63 64 ), 65 'signup_info' => _x( '(Sign-up)', 'xProfile Group Admin Screen Signup field information', 'buddypress' ), 64 66 ); 65 67 66 68 foreach ( bp_xprofile_get_field_types() as $field_type => $field_type_class ) { -
src/bp-xprofile/bp-xprofile-filters.php
diff --git src/bp-xprofile/bp-xprofile-filters.php src/bp-xprofile/bp-xprofile-filters.php index 7a2fc06be..1f21f1f01 100644
function bp_xprofile_register_personal_data_exporter( $exporters ) { 691 691 692 692 return $exporters; 693 693 } 694 695 /** 696 * Used to edit the field input name inside the xProfile Admin Screen 697 * 698 * @see bp_xprofile_admin_get_signup_field() 699 * 700 * @since 8.0.0 701 * 702 * @param string $field_selector The text to use as the input name/id attribute. 703 * @return string The text to use as the input name/id attribute. 704 */ 705 function bp_get_the_profile_signup_field_input_name( $field_selector = '' ) { 706 global $field; 707 708 if ( isset( $field->id ) && $field->id ) { 709 $field_selector = sprintf( 'signup_field_%d', $field->id ); 710 } 711 712 return $field_selector; 713 } 714 715 /** 716 * Provides Signup fields argument back compatibility for template overrides. 717 * 718 * @since 8.0.0 719 * @access private 720 * 721 * @param array $args The xProfile loop's signup arguments. 722 * @return array The xProfile loop's signup arguments. 723 */ 724 function _bp_xprofile_signup_do_backcompat( $args = array() ) { 725 $expected_args = bp_xprofile_signup_args(); 726 $needed_args = array_intersect_key( $args, $expected_args ); 727 728 if ( 1 === $args['profile_group_id'] || array_diff_key( $expected_args, $needed_args ) ) { 729 _doing_it_wrong( 'bp_has_profile()', __( 'The argument of this function into your custom `members/register.php` template should be bp_xprofile_signup_args()', 'buddypress' ), '8.0.0' ); 730 $args = $expected_args; 731 } 732 733 return $args; 734 } 735 736 /** 737 * Checks whether back compatibility is needed about xProfile loop's signup arguments. 738 * 739 * @since 8.0.0 740 * @access private 741 * 742 * @param string $template The located path for registration template. 743 * @param string $template_name The needed template name. 744 */ 745 function _bp_xprofile_signup_check_backcompat( $template = '', $template_name = '' ) { 746 if ( 'members/register.php' !== $template_name ) { 747 return; 748 } 749 750 if ( 0 !== strpos( $template, buddypress()->theme_compat->theme->dir ) ) { 751 add_filter( 'bp_after_has_profile_parse_args', '_bp_xprofile_signup_do_backcompat', 100 ); 752 } 753 } 754 755 /** 756 * Starts Signup fields back compatibility process only on the signup's page. 757 * 758 * @since 8.0.0 759 * @access private 760 */ 761 function _bp_xprofile_signup_start_backcompat() { 762 add_action( 'bp_locate_template', '_bp_xprofile_signup_check_backcompat', 10, 2 ); 763 } 764 add_action( 'bp_core_screen_signup', '_bp_xprofile_signup_start_backcompat' ); -
src/bp-xprofile/bp-xprofile-functions.php
diff --git src/bp-xprofile/bp-xprofile-functions.php src/bp-xprofile/bp-xprofile-functions.php index 9764102f4..dfc56013c 100644
function bp_xprofile_get_wp_user_keys() { 1420 1420 array_keys( wp_get_user_contact_methods() ) 1421 1421 ); 1422 1422 } 1423 1424 /** 1425 * Returns the signup field IDs. 1426 * 1427 * @since 8.0.0 1428 * 1429 * @return int[] The signup field IDs. 1430 */ 1431 function bp_xprofile_get_signup_field_ids() { 1432 $signup_field_ids = wp_cache_get( 'signup_fields', 'bp_xprofile' ); 1433 1434 if ( ! $signup_field_ids ) { 1435 global $wpdb; 1436 $bp = buddypress(); 1437 1438 $signup_field_ids = $wpdb->get_col( "SELECT object_id FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND meta_key = 'signup_position' ORDER BY meta_value ASC" ); 1439 1440 wp_cache_set( 'signup_fields', $signup_field_ids, 'bp_xprofile' ); 1441 } 1442 1443 return array_map( 'intval', $signup_field_ids ); 1444 } 1445 1446 /** 1447 * Returns xProfile loop's signup arguments. 1448 * 1449 * @since 8.0.0 1450 * 1451 * @param array $extra Optional extra arguments. 1452 * @return array The xProfile loop's signup arguments. 1453 */ 1454 function bp_xprofile_signup_args( $extra = array() ) { 1455 return array_merge( 1456 array( 1457 'fetch_fields' => true, 1458 'fetch_field_data' => false, 1459 'signup_fields_only' => true, 1460 ), 1461 $extra 1462 ); 1463 } -
src/bp-xprofile/bp-xprofile-template.php
diff --git src/bp-xprofile/bp-xprofile-template.php src/bp-xprofile/bp-xprofile-template.php index 10b5188c9..78fff208c 100644
defined( 'ABSPATH' ) || exit; 15 15 * 16 16 * @since 1.0.0 17 17 * @since 2.4.0 Introduced `$member_type` argument. 18 * @since 8.0.0 Introduced `$hide_field_types` argument.18 * @since 8.0.0 Introduced `$hide_field_types` & `$signup_fields_only` arguments. 19 19 * 20 20 * @global object $profile_template 21 21 * @see BP_XProfile_Group::get() for full description of `$args` array. … … defined( 'ABSPATH' ) || exit; 36 36 * @type int[]|bool $exclude_groups Default: false. 37 37 * @type int[]|bool $exclude_fields Default: false. 38 38 * @type string[] $hide_field_types Default: empty array. 39 * @type bool $signup_fields_only Default: false. 39 40 * @type bool $update_meta_cache Default: true. 40 41 * } 41 42 * … … function bp_has_profile( $args = '' ) { 68 69 'exclude_groups' => false, // Comma-separated list of profile field group IDs to exclude. 69 70 'exclude_fields' => false, // Comma-separated list of profile field IDs to exclude. 70 71 'hide_field_types' => array(), // List of field types to hide from profile fields loop. 72 'signup_fields_only' => false, // Whether to only return signup fields. 71 73 'update_meta_cache' => true, 72 74 ), 'has_profile' ); 73 75 -
src/bp-xprofile/classes/class-bp-xprofile-data-template.php
diff --git src/bp-xprofile/classes/class-bp-xprofile-data-template.php src/bp-xprofile/classes/class-bp-xprofile-data-template.php index 8aa3a4909..ca478f174 100644
class BP_XProfile_Data_Template { 105 105 * 106 106 * @since 1.5.0 107 107 * @since 2.4.0 Introduced `$member_type` argument. 108 * @since 8.0.0 Introduced `$hide_field_types` argument.108 * @since 8.0.0 Introduced `$hide_field_types` & `$signup_fields_only` arguments. 109 109 * 110 110 * @param array|string $args { 111 111 * An array of arguments. All items are optional. … … class BP_XProfile_Data_Template { 120 120 * @type array $exclude_fields Exclude these fields. 121 121 * @type int|bool $hide_empty_fields Should empty fields be skipped. 122 122 * @type int|bool $fetch_visibility_level Fetch visibility levels. 123 * @type int|bool $update_meta_cache Should metadata cache be updated.124 123 * @type string[] $hide_field_types List of field types to hide form loop. Default: empty array. 124 * @type bool $signup_fields_only Whether to only return signup fields. Default: false. 125 * @type int|bool $update_meta_cache Should metadata cache be updated. 125 126 * } 126 127 */ 127 128 public function __construct( $args = '' ) { … … class BP_XProfile_Data_Template { 159 160 'exclude_groups' => false, 160 161 'exclude_fields' => false, 161 162 'hide_field_types' => array(), 163 'signup_fields_only' => false, 162 164 'update_meta_cache' => true 163 165 ) ); 164 166 165 $this->groups = bp_xprofile_get_groups( $r ); 167 $groups = bp_xprofile_get_groups( $r ); 168 169 if ( true === $r['signup_fields_only'] && bp_get_signup_allowed() ) { 170 $signup_fields_order = bp_xprofile_get_signup_field_ids(); 171 $signup_group = new BP_XProfile_Group(); 172 $signup_group->id = 0; 173 $signup_group->name = __( 'Signup Fields', 'buddypress' ); 174 $signup_group->description = ''; 175 $signup_group->can_delete = 0; 176 $signup_group->group_order = 0; 177 $fields = array(); 178 $signup_group->fields = array(); 179 180 // Get all group fields. 181 foreach ( $groups as $group ) { 182 if ( ! $group->fields ) { 183 continue; 184 } 185 186 // Populate fields using the field ID as key. 187 foreach ( $group->fields as $signup_field ) { 188 $fields[ $signup_field->id ] = $signup_field; 189 } 190 } 191 192 if ( $fields ) { 193 // Reorder signup fields. 194 foreach ( $signup_fields_order as $ordered_signup_field_id ) { 195 if ( ! isset( $fields[ $ordered_signup_field_id ] ) ) { 196 continue; 197 } 198 199 $signup_group->fields[] = $fields[ $ordered_signup_field_id ]; 200 } 201 } 202 203 // Override groups with the signup one. 204 $groups = array( $signup_group ); 205 } 206 207 $this->groups = $groups; 166 208 $this->group_count = count( $this->groups ); 167 209 $this->user_id = $r['user_id']; 168 210 } -
src/bp-xprofile/classes/class-bp-xprofile-field-type-wordpress-textbox.php
diff --git src/bp-xprofile/classes/class-bp-xprofile-field-type-wordpress-textbox.php src/bp-xprofile/classes/class-bp-xprofile-field-type-wordpress-textbox.php index 3c5828a73..0a2d17404 100644
class BP_XProfile_Field_Type_WordPress_Textbox extends BP_XProfile_Field_Type_Wo 144 144 $this->wp_user_key = self::get_field_settings( bp_get_the_profile_field_id() ); 145 145 } 146 146 147 $field_value = ''; 147 148 if ( 'user_url' === $this->wp_user_key ) { 148 149 if ( bp_displayed_user_id() ) { 149 150 $field_value = bp_get_displayed_user()->userdata->{$this->wp_user_key}; -
src/bp-xprofile/classes/class-bp-xprofile-field-type-wordpress.php
diff --git src/bp-xprofile/classes/class-bp-xprofile-field-type-wordpress.php src/bp-xprofile/classes/class-bp-xprofile-field-type-wordpress.php index 153cae0cc..fc48228b8 100644
abstract class BP_XProfile_Field_Type_WordPress extends BP_XProfile_Field_Type { 56 56 'do_autolink' => false, 57 57 'allow_custom_visibility' => false, 58 58 'member_types' => false, 59 'signup_position' => true, 59 60 ); 60 61 61 62 /** -
src/bp-xprofile/classes/class-bp-xprofile-field.php
diff --git src/bp-xprofile/classes/class-bp-xprofile-field.php src/bp-xprofile/classes/class-bp-xprofile-field.php index 55318cfd6..b32b5c928 100644
class BP_XProfile_Field { 139 139 */ 140 140 public $do_autolink; 141 141 142 /** 143 * The signup position of the field into the signups form. 144 * 145 * @since 8.0.0 146 * @var int 147 */ 148 public $signup_position; 149 142 150 /** 143 151 * Field type option. 144 152 * … … class BP_XProfile_Field { 859 867 return $this->allow_custom_visibility; 860 868 } 861 869 870 /** 871 * Get the field's signup position. 872 * 873 * @since 8.0.0 874 * 875 * @return int the field's signup position. 876 * 0 if the field has not been added to the signup form. 877 */ 878 public function get_signup_position() { 879 if ( ! isset( $this->signup_position ) ) { 880 $this->signup_position = (int) bp_xprofile_get_meta( $this->id, 'field', 'signup_position' ); 881 } 882 883 return $this->signup_position; 884 } 885 862 886 /** 863 887 * Get whether the field values should be auto-linked to a directory search. 864 888 * … … class BP_XProfile_Field { 1277 1301 // Output the required metabox. 1278 1302 $this->required_metabox(); 1279 1303 1304 // Output signup position metabox. 1305 $this->signup_position_metabox(); 1306 1280 1307 // Output the Member Types metabox. 1281 1308 $this->member_type_metabox(); 1282 1309 … … class BP_XProfile_Field { 1345 1372 public function get_field_type_supports() { 1346 1373 $supports = array( 1347 1374 'switch_fieldtype' => true, 1348 ' allow_required'=> true,1349 ' allow_autolink'=> true,1375 'required' => true, 1376 'do_autolink' => true, 1350 1377 'allow_custom_visibility' => true, 1351 1378 'member_types' => true, 1379 'signup_position' => true, 1352 1380 ); 1353 1381 1354 1382 if ( isset( $this->type_obj ) && $this->type_obj ) { … … class BP_XProfile_Field { 1502 1530 * Private method used to output field Member Type metabox. 1503 1531 * 1504 1532 * @since 2.4.0 1533 * 1534 * @return void If default field or if the field does not support the feature. 1505 1535 */ 1506 1536 private function member_type_metabox() { 1507 1537 1508 1538 // The primary field is for all, so bail. 1509 if ( 1 === (int) $this->id|| ! $this->field_type_supports( 'member_types' ) ) {1539 if ( true === $this->is_default_field() || ! $this->field_type_supports( 'member_types' ) ) { 1510 1540 return; 1511 1541 } 1512 1542 … … class BP_XProfile_Field { 1556 1586 * 1557 1587 * @since 2.3.0 1558 1588 * 1559 * @return void If default field id 1.1589 * @return void If default field or if the field does not support the feature. 1560 1590 */ 1561 1591 private function visibility_metabox() { 1562 1592 … … class BP_XProfile_Field { 1605 1635 * 1606 1636 * @since 2.3.0 1607 1637 * 1608 * @return void If default field .1638 * @return void If default field or if the field does not support the feature. 1609 1639 */ 1610 1640 private function required_metabox() { 1611 1641 … … class BP_XProfile_Field { 1632 1662 * 1633 1663 * @since 2.5.0 1634 1664 * 1635 * @return void If default field id 1.1665 * @return void If the field does not support the feature. 1636 1666 */ 1637 1667 private function autolink_metabox() { 1638 1668 … … class BP_XProfile_Field { 1705 1735 <?php 1706 1736 } 1707 1737 1738 /** 1739 * Output the metabox for setting the field's position into the signup form. 1740 * 1741 * @since 8.0.0 1742 * 1743 * @return void If default field or if the field does not support the feature. 1744 */ 1745 private function signup_position_metabox() { 1746 // Field types not supporting the feature cannot be added to signups form. 1747 if ( ! $this->field_type_supports( 'signup_position' ) || true === $this->is_default_field() ) { 1748 return; 1749 } 1750 1751 $next_signup_position = 1; 1752 $signup_position = $this->get_signup_position(); 1753 1754 if ( 0 === $signup_position ) { 1755 $signup_fields_order = bp_xprofile_get_signup_field_ids(); 1756 $next_signup_position = count( $signup_fields_order ) + 1; 1757 } else { 1758 $next_signup_position = $signup_position; 1759 } 1760 ?> 1761 1762 <div class="postbox" id="field-signup-position-metabox"> 1763 <h2><label for="default-visibility"><?php esc_html_e( 'Signups', 'buddypress' ); ?></label></h2> 1764 <div class="inside"> 1765 <div> 1766 <ul> 1767 <li> 1768 <input type="checkbox" id="has-signup-position" name="signup-position" value="<?php echo esc_attr( $next_signup_position ); ?>" <?php checked( $signup_position, $next_signup_position ); ?> /> 1769 <label for="has-signup-position"><?php esc_html_e( 'Use the field into the registration form.', 'buddypress' ); ?></label> 1770 </li> 1771 </ul> 1772 </div> 1773 </div> 1774 </div> 1775 <?php 1776 } 1777 1708 1778 /** 1709 1779 * Output hidden fields used by default field. 1710 1780 * … … class BP_XProfile_Field { 1754 1824 'id' => 'fieldtype', 1755 1825 'value' => 'textbox', 1756 1826 ), 1827 array( 1828 'name' => 'signup-position', 1829 'id' => 'has-signup-position', 1830 'value' => $this->get_signup_position(), 1831 ), 1757 1832 ); 1758 1833 } 1759 1834 -
src/bp-xprofile/classes/class-bp-xprofile-group.php
diff --git src/bp-xprofile/classes/class-bp-xprofile-group.php src/bp-xprofile/classes/class-bp-xprofile-group.php index b6f196838..6b50d35b6 100644
class BP_XProfile_Group { 238 238 * 239 239 * @since 1.2.0 240 240 * @since 2.4.0 Introduced `$member_type` argument. 241 * @since 8.0.0 Introduced `$hide_field_types` argument.241 * @since 8.0.0 Introduced `$hide_field_types` & `$signup_fields_only` arguments. 242 242 * 243 243 * @global object $wpdb WordPress DB access object. 244 244 * 245 245 * @param array $args { 246 246 * Array of optional arguments: 247 * @type int $profile_group_id Limit results to a single profile group. 248 * @type int $user_id Required if you want to load a specific user's data. 249 * Default: displayed user's ID. 250 * @type array|string $member_type Limit fields by those restricted to a given member type, or array of 251 * member types. If `$user_id` is provided, the value of `$member_type` 252 * will be overridden by the member types of the provided user. The 253 * special value of 'any' will return only those fields that are 254 * unrestricted by member type - i.e., those applicable to any type. 255 * @type bool $hide_empty_groups True to hide groups that don't have any fields. Default: false. 256 * @type bool $hide_empty_fields True to hide fields where the user has not provided data. 257 * Default: false. 258 * @type bool $fetch_fields Whether to fetch each group's fields. Default: false. 259 * @type bool $fetch_field_data Whether to fetch data for each field. Requires a $user_id. 260 * Default: false. 261 * @type int[]|bool $exclude_groups Comma-separated list or array of group IDs to exclude. 262 * @type int[]|bool $exclude_fields Comma-separated list or array of field IDs to exclude. 263 * @type string[] $hide_field_types List of field types to hide form loop. Default: empty array. 264 * @type bool $update_meta_cache Whether to pre-fetch xprofilemeta for all retrieved groups, fields, 265 * and data. Default: true. 247 * @type int $profile_group_id Limit results to a single profile group. 248 * @type int $user_id Required if you want to load a specific user's data. 249 * Default: displayed user's ID. 250 * @type array|string $member_type Limit fields by those restricted to a given member type, or array of 251 * member types. If `$user_id` is provided, the value of `$member_type` 252 * will be overridden by the member types of the provided user. The 253 * special value of 'any' will return only those fields that are 254 * unrestricted by member type - i.e., those applicable to any type. 255 * @type bool $hide_empty_groups True to hide groups that don't have any fields. Default: false. 256 * @type bool $hide_empty_fields True to hide fields where the user has not provided data. 257 * Default: false. 258 * @type bool $fetch_fields Whether to fetch each group's fields. Default: false. 259 * @type bool $fetch_field_data Whether to fetch data for each field. Requires a $user_id. 260 * Default: false. 261 * @type int[]|bool $exclude_groups Comma-separated list or array of group IDs to exclude. 262 * @type int[]|bool $exclude_fields Comma-separated list or array of field IDs to exclude. 263 * @type string[] $hide_field_types List of field types to hide form loop. Default: empty array. 264 * @type bool $signup_fields_only Whether to only return signup fields. Default: false. 265 * @type bool $update_meta_cache Whether to pre-fetch xprofilemeta for all retrieved groups, fields, 266 * and data. Default: true. 266 267 * } 267 268 * @return array $groups 268 269 */ … … class BP_XProfile_Group { 283 284 'exclude_fields' => false, 284 285 'hide_field_types' => array(), 285 286 'update_meta_cache' => true, 287 'signup_fields_only' => false, 286 288 ) ); 287 289 288 290 // Keep track of object IDs for cache-priming. … … class BP_XProfile_Group { 342 344 // Pull field objects from the cache. 343 345 $fields = array(); 344 346 foreach ( $field_ids as $field_id ) { 347 if ( true === $r['signup_fields_only'] && ! in_array( $field_id, bp_xprofile_get_signup_field_ids(), true ) ) { 348 continue; 349 } 350 345 351 $_field = xprofile_get_field( $field_id, null, false ); 346 352 347 353 if ( in_array( $_field->type, $r['hide_field_types'], true ) ) {