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: ''
- 'field_id'
Return
(string) $retval
Source
File: bp-xprofile/bp-xprofile-template.php
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
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.