Skip to:
Content

BuddyPress.org

Ticket #8477: 8477.patch

File 8477.patch, 7.6 KB (added by imath, 2 years ago)
  • src/bp-xprofile/bp-xprofile-admin.php

    diff --git src/bp-xprofile/bp-xprofile-admin.php src/bp-xprofile/bp-xprofile-admin.php
    index c76512bf7..0c312541d 100644
    function xprofile_admin_screen( $message = '', $type = 'error' ) { 
    188188
    189189                                        <?php endforeach; endif; ?>
    190190
    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; ?>
     191                                        <li id="signup-group" class="not-sortable last">
     192                                                <a href="#tabs-signup-group" class="ui-tab">
     193                                                        <?php esc_html_e( 'Signup Fields', 'buddypress' ); ?>
     194                                                </a>
     195                                        </li>
    198196
    199197                                </ul>
    200198
    function xprofile_admin_screen( $message = '', $type = 'error' ) { 
    312310                                <?php endif; ?>
    313311
    314312                                <?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                                                                                 }
     313                                $signup_groups = bp_xprofile_get_groups(
     314                                        array(
     315                                                'fetch_fields'       => true,
     316                                                'signup_fields_only' => true,
     317                                        )
     318                                );
     319                                $has_signup_fields   = false;
     320                                $signup_fields       = array();
     321                                $signup_fields_order = bp_xprofile_get_signup_field_ids();
     322                                ?>
     323                                <div id="tabs-signup-group"" class="tab-wrapper">
     324                                        <div class="tab-toolbar">
     325                                                <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>
     326                                        </div>
     327                                        <fieldset id="signup-fields" class="connectedSortable field-group" aria-live="polite" aria-atomic="true" aria-relevant="all">
     328                                                <legend class="screen-reader-text">
     329                                                        <?php esc_html_e( 'Fields to use into the registration form', 'buddypress' );?>
     330                                                </legend>
     331
     332                                                <?php
     333                                                if ( ! empty( $signup_groups ) ) {
     334                                                        foreach ( $signup_groups as $signup_group ) {
     335                                                                if ( ! empty( $signup_group->fields ) ) {
     336                                                                        $has_signup_fields = true;
     337
     338                                                                        foreach ( $signup_group->fields as $signup_field ) {
     339                                                                                // Load the field.
     340                                                                                $_signup_field = xprofile_get_field( $signup_field, null, false );
     341
     342                                                                                /**
     343                                                                                 * This function handles the WYSIWYG profile field
     344                                                                                 * display for the xprofile admin setup screen.
     345                                                                                 */
     346                                                                                $signup_fields[ $_signup_field->id ] = bp_xprofile_admin_get_signup_field( $_signup_field, $signup_group, '' );
    352347                                                                        }
    353348                                                                }
     349                                                        }
    354350
    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 ];
     351                                                        // Output signup fields according to their signup position.
     352                                                        foreach ( $signup_fields_order as $ordered_signup_field_id ) {
     353                                                                if ( ! isset( $signup_fields[ $ordered_signup_field_id ] ) ) {
     354                                                                        continue;
    362355                                                                }
    363                                                         }
    364356
    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
     357                                                                echo $signup_fields[ $ordered_signup_field_id ];
    369358                                                        }
     359                                                }
     360
     361                                                if ( ! $has_signup_fields ) {
    370362                                                        ?>
    371                                                 </fieldset>
     363                                                        <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>
     364                                                        <?php
     365                                                }
     366                                                ?>
     367                                        </fieldset>
    372368
     369                                        <?php if ( bp_get_signup_allowed() ) : ?>
    373370                                                <p><?php esc_html_e( '* Fields in this group appear on the registration page.', 'buddypress' ); ?></p>
    374                                         </div>
    375                                         <?php
    376                                 }
    377                                 ?>
     371                                        <?php else : ?>
     372                                                <p>
     373                                                        <?php
     374                                                        // Include a link to edit settings.
     375                                                        $settings_link = '';
     376
     377                                                        if ( is_multisite() && current_user_can( 'manage_network_users') ) {
     378                                                                $settings_link = sprintf(
     379                                                                        ' <a href="%1$">%2$s</a>.',
     380                                                                        esc_url( network_admin_url( 'settings.php' ) ),
     381                                                                        esc_html__( 'Edit settings', 'buddypress' )
     382                                                                );
     383                                                        } elseif ( current_user_can( 'manage_options' ) ) {
     384                                                                $settings_link = sprintf(
     385                                                                        ' <a href="%1$s">%2$s</a>.',
     386                                                                        esc_url( bp_get_admin_url( 'options-general.php' ) ),
     387                                                                        esc_html__( 'Edit settings', 'buddypress' )
     388                                                                );
     389                                                        }
     390
     391                                                        printf(
     392                                                                /* translators: %s is the link to the registration settings. */
     393                                                                esc_html__( '* Fields in this group will appear on the registration page as soon as users will be able to register to your site.%s', 'buddypress' ),
     394                                                                $settings_link
     395                                                        );
     396                                                        ?>
     397                                                </p>
     398                                        <?php endif; ?>
     399                                </div>
    378400                        </div>
    379401                </form>
    380402        </div>
    function xprofile_admin_field( $admin_field, $admin_group, $class = '', $is_sign 
    10291051
    10301052                                <?php if ( empty( $field->can_delete ) ) : ?><?php esc_html_e( '(Primary)', 'buddypress' ); endif; ?>
    10311053                                <?php bp_the_profile_field_required_label(); ?>
    1032                                 <?php if ( bp_get_signup_allowed() && $field->get_signup_position() ) : ?>
     1054                                <?php if ( $field->get_signup_position() ) : ?>
    10331055                                        <span class="bp-signup-field-label"><?php esc_html_e( '(Sign-up)', 'buddypress' );?></span>
    10341056                                <?php endif; ?>
    10351057                                <?php if ( bp_get_member_types() ) : echo $field->get_member_type_label(); endif; ?>
  • 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 ca478f174..118e5961e 100644
    class BP_XProfile_Data_Template { 
    166166
    167167                $groups = bp_xprofile_get_groups( $r );
    168168
    169                 if ( true === $r['signup_fields_only'] && bp_get_signup_allowed() ) {
     169                if ( true === $r['signup_fields_only'] ) {
    170170                        $signup_fields_order       = bp_xprofile_get_signup_field_ids();
    171171                        $signup_group              = new BP_XProfile_Group();
    172172                        $signup_group->id          = 0;