Ticket #6347: 6347.02.patch
| File 6347.02.patch, 6.0 KB (added by , 11 years ago) |
|---|
-
src/bp-templates/bp-legacy/buddypress/members/register.php
63 63 <h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4> 64 64 65 65 <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> 66 <?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(); ?>66 <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile_signup() ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 67 67 68 68 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 69 69 -
src/bp-xprofile/bp-xprofile-admin.php
365 365 // Validate default visibility 366 366 if ( ! empty( $_POST['default-visibility'] ) && in_array( $_POST['default-visibility'], wp_list_pluck( bp_xprofile_get_visibility_levels(), 'id' ) ) ) { 367 367 bp_xprofile_update_field_meta( $field_id, 'default_visibility', $_POST['default-visibility'] ); 368 } else { 369 bp_xprofile_delete_meta( $field_id, 'field', 'default_visibility' ); 368 370 } 369 371 370 372 // Validate custom visibility 371 if ( ! empty( $_POST['allow-custom-visibility'] ) && in_array( $_POST['allow-custom-visibility'], array( 'allowed', 'disa llowed' ) ) ) {373 if ( ! empty( $_POST['allow-custom-visibility'] ) && in_array( $_POST['allow-custom-visibility'], array( 'allowed', 'disabled' ) ) ) { 372 374 bp_xprofile_update_field_meta( $field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility'] ); 375 } else { 376 bp_xprofile_delete_meta( $field_id, 'field', 'allow_custom_visibility' ); 373 377 } 374 378 379 // Validate signup 380 if ( ! empty( $_POST['signup-position'] ) ) { 381 bp_xprofile_update_field_meta( $field_id, 'signup_position', (int) $_POST['signup-position'] ); 382 } else { 383 bp_xprofile_delete_meta( $field_id, 'field', 'signup_position' ); 384 } 385 375 386 /** 376 387 * Fires at the end of the process to save a field for a user, if successful. 377 388 * … … 489 500 <legend> 490 501 <span> 491 502 <?php bp_the_profile_field_name(); ?> 492 <?php if ( ! $field->can_delete ) : ?> <?php _e( '(Primary)', 'buddypress' ); endif; ?> 493 <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(Required)', 'buddypress' ) ?><?php endif; ?> 503 504 <?php if ( empty( $field->can_delete ) ) : ?><?php esc_html_e( '(Primary)', 'buddypress' ); endif; ?> 505 <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php esc_html_e( '(Required)', 'buddypress' ); endif; ?> 506 <?php if ( bp_xprofile_get_meta( $field->id, 'field', 'signup_position' ) ) : ?><?php esc_html_e( '(Sign-up)', 'buddypress' ); endif; ?> 507 494 508 <?php 495 509 496 510 /** -
src/bp-xprofile/bp-xprofile-template.php
298 298 return apply_filters( 'bp_has_profile', $profile_template->has_groups(), $profile_template ); 299 299 } 300 300 301 /** 302 * Query XProfile fields used during signup in `register.php` template part 303 * 304 * @since BuddyPress (2.3.0) 305 * 306 * @param mixed $args 307 */ 308 function bp_has_profile_signup( $args = '' ) { 309 310 // Parse signup arguments 311 $r = bp_parse_args( $args, array( 312 'profile_group_id' => 1, 313 'fetch_field_data' => false 314 ), 'signup_fields' ); 315 316 // Query for profile fields to show in signup 317 return bp_has_profile( $r ); 318 } 319 301 320 function bp_profile_groups() { 302 321 global $profile_template; 303 322 return $profile_template->profile_groups(); -
src/bp-xprofile/classes/class-bp-xprofile-field.php
110 110 public $allow_custom_visibility = 'allowed'; 111 111 112 112 /** 113 * @since BuddyPress (2.3.0) 114 * 115 * @var int Position of field on user registration page 116 */ 117 public $signup_position = null; 118 119 /** 113 120 * @since BuddyPress (2.0.0) 114 121 * 115 122 * @var BP_XProfile_Field_Type Field type object used for validation … … 191 198 // Get metadata for field 192 199 $default_visibility = bp_xprofile_get_meta( $id, 'field', 'default_visibility' ); 193 200 $allow_custom_visibility = bp_xprofile_get_meta( $id, 'field', 'allow_custom_visibility' ); 201 $signup_position = bp_xprofile_get_meta( $id, 'field', 'signup_position' ); 194 202 195 203 // Setup default visibility 196 204 $this->default_visibility = ! empty( $default_visibility ) … … 201 209 $this->allow_custom_visibility = ( 'disabled' === $allow_custom_visibility ) 202 210 ? 'disabled' 203 211 : 'allowed'; 212 213 // Is this field used on the registration page 214 $this->signup_position = ( false !== $signup_position ) 215 ? $signup_position 216 : null; 204 217 } 205 218 } 206 219 … … 680 693 // Output the required metabox 681 694 $this->required_metabox(); 682 695 683 // Output the field visibility metabox es696 // Output the field visibility metabox 684 697 $this->visibility_metabox(); 685 698 699 // Output the signup metabox 700 $this->signup_metabox(); 701 686 702 /** 687 703 * Fires after XProfile Field sidebar metabox. 688 704 * … … 902 918 } 903 919 904 920 /** 921 * Output the metabox for enabling this field to appear on user registration 922 * 923 * @since BuddyPress (2.3.0) 924 */ 925 private function signup_metabox() { 926 ?> 927 928 <div class="postbox"> 929 <h3><label for="signup-field"><?php _e( 'Sign Ups', 'buddypress' ); ?></label></h3> 930 <div class="inside"> 931 <ul> 932 <li> 933 <input type="checkbox" id="signup-position" name="signup-position" value="1" <?php checked( $this->signup_position, ! null ); ?> /> 934 <label for="signup-position"><?php esc_html_e( 'Display on Registration', 'buddypress' ); ?></label> 935 </li> 936 </ul> 937 </div> 938 </div> 939 940 <?php 941 } 942 943 /** 905 944 * Output the metabox for setting what type of field this is 906 945 * 907 946 * @since BuddyPress (2.3.0)