bp_profile_get_visibility_radio_buttons( array|string $args = '' )

Return the field visibility radio buttons.

Description

Parameters

$args

(Optional) Args for the radio buttons.

  • 'field_id'
    (int) ID of the field to render.
  • 'before'
    (string) Markup to render before the field.
  • 'after'
    (string) Markup to render after the field.
  • 'before_radio'
    (string) Markup to render before the radio button.
  • 'after_radio'
    (string) Markup to render after the radio button.
  • 'class'
    (string) Class to apply to the field markup.

Default value: ''

Return

(string) $retval

Source

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

1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
function bp_profile_get_visibility_radio_buttons( $args = '' ) {
 
    // Parse optional arguments.
    $r = bp_parse_args( $args, array(
        'field_id'     => bp_get_the_profile_field_id(),
        'before'       => '<div class="radio">',
        'after'        => '</div>',
        'before_radio' => '',
        'after_radio'  => '',
        'class'        => 'bp-xprofile-visibility'
    ), 'xprofile_visibility_radio_buttons' );
 
    // 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 foreach( bp_xprofile_get_visibility_levels() as $level ) : ?>
 
                <?php printf( $r['before_radio'], esc_attr( $level['id'] ) ); ?>
 
                <label for="<?php echo esc_attr( 'see-field_' . $r['field_id'] . '_' . $level['id'] ); ?>">
                    <input type="radio" id="<?php echo esc_attr( 'see-field_' . $r['field_id'] . '_' . $level['id'] ); ?>" name="<?php echo esc_attr( 'field_' . $r['field_id'] . '_visibility' ); ?>" value="<?php echo esc_attr( $level['id'] ); ?>" <?php checked( $level['id'], bp_get_the_profile_field_visibility_level() ); ?> />
                    <span class="field-visibility-text"><?php echo esc_html( $level['label'] ); ?></span>
                </label>
 
                <?php echo $r['after_radio']; ?>
 
            <?php endforeach; ?>
 
        <?php endif;
 
        // Output anything after.
        echo $r['after'];
 
        // Get the output buffer and empty it.
        $retval = ob_get_clean();
    endif;
 
    /**
     * Filters the radio buttons for setting visibility.
     *
     * @since BuddyPress 1.6.0
     *
     * @param string $retval HTML output for the visibility radio buttons.
     * @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_get_visibility_radio_buttons', $retval, $r, $args );
}

Changelog

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