bp_profile_get_settings_visibility_select( array|string $args = '' )

Return the XProfile field visibility select list for settings.

Description

Parameters

$args

(Optional) Args for the select list.

  • 'field_id'
    (int) ID of the field to render.
  • 'before'
    (string) Markup to render before the field.
  • 'before_controls'
    (string) markup before form controls.
  • 'after'
    (string) Markup to render after the field.
  • 'after_controls'
    (string) Markup after the form controls.
  • 'class'
    (string) Class to apply to the field markup.
  • 'label_class'
    (string) Class to apply for the label element.
  • 'notoggle_tag'
    (string) Markup element to use for notoggle tag.
  • 'notoggle_class'
    (string) Class to apply to the notoggle element.

Default value: ''

Return

(string) $retval

Source

File: bp-xprofile/bp-xprofile-template.php

1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
function bp_profile_get_settings_visibility_select( $args = '' ) {
 
    // Parse optional arguments.
    $r = bp_parse_args( $args, array(
        'field_id'         => bp_get_the_profile_field_id(),
        'before'           => '',
        'before_controls'  => '',
        'after'            => '',
        'after_controls'   => '',
        'class'            => 'bp-xprofile-visibility',
        'label_class'      => 'bp-screen-reader-text',
        'notoggle_tag'     => 'span',
        'notoggle_class'   => 'field-visibility-settings-notoggle',
    ), 'xprofile_settings_visibility_select' );
 
    // Empty return value, filled in below if a valid field ID is found.
    $retval = '';
 
    // Only do-the-do if there's a valid field ID.
    if ( ! empty( $r['field_id'] ) ) :
 
        // Start the output buffer.
        ob_start();
 
        // Output anything before.
        echo $r['before']; ?>
 
        <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
 
        <?php echo $r['before_controls']; ?>
 
            <label for="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility" class="<?php echo esc_attr( $r['label_class'] ); ?>"><?php
                /* translators: accessibility text */
                _e( 'Select visibility', 'buddyboss' );
            ?></label>
            <select class="<?php echo esc_attr( $r['class'] ); ?>" name="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility" id="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility">
 
                <?php foreach ( bp_xprofile_get_visibility_levels() as $level ) : ?>
 
                    <option value="<?php echo esc_attr( $level['id'] ); ?>" <?php selected( $level['id'], bp_get_the_profile_field_visibility_level() ); ?>><?php echo esc_html( $level['label'] ); ?></option>
 
                <?php endforeach; ?>
 
            </select>
 
        <?php echo $r['after_controls']; ?>
 
        <?php else : ?>
 
            <<?php echo esc_html( $r['notoggle_tag'] ); ?> class="<?php echo esc_attr( $r['notoggle_class'] ); ?>"><?php bp_the_profile_field_visibility_level_label(); ?></<?php echo esc_html( $r['notoggle_tag'] ); ?>>
 
        <?php endif;
 
        // Output anything after.
        echo $r['after'];
 
        // Get the output buffer and empty it.
        $retval = ob_get_clean();
    endif;
 
    /**
     * Filters the dropdown list for setting visibility.
     *
     * @since BuddyPress 2.0.0
     *
     * @param string $retval HTML output for the visibility dropdown list.
     * @param array  $r      Parsed arguments to be used with display.
     * @param array  $args   Original passed in arguments to be used with display.
     */
    return apply_filters( 'bp_profile_settings_visibility_select', $retval, $r, $args );
}

Changelog

Changelog
Version Description
BuddyPress 2.0.0 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.