xprofile_admin_screen( string $message = '', string $type = 'error' )
Output the main XProfile management screen.
Description
Parameters
- $message
-
(Optional) Feedback message.
Default value: ''
- $type
-
(Optional) Feedback type.
Default value: 'error'
Source
File: bp-xprofile/bp-xprofile-admin.php
function xprofile_admin_screen( $message = '', $type = 'error' ) { // Users admin URL $url = bp_get_admin_url( 'admin.php' ); // Add Group $add_group_url = add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'add_group' ), $url ); // Validate type. $type = preg_replace( '|[^a-z]|i', '', $type ); // Get all of the profile groups & fields. $groups = bp_xprofile_get_groups( array( 'fetch_fields' => true ) ); ?> <div class="wrap"> <?php $users_tab = count( bp_core_get_users_admin_tabs() ); if ( $users_tab > 1 ) { ?> <h2 class="nav-tab-wrapper"><?php bp_core_admin_users_tabs( __( 'Profile Fields', 'buddyboss' ) ); ?></h2><?php } ?> </div> <div class="wrap"> <?php if ( version_compare( $GLOBALS['wp_version'], '4.8', '>=' ) ) : ?> <h1 class="wp-heading-inline"><?php _e( 'Profile Fields', 'buddyboss'); ?></h1> <a id="add_group" class="page-title-action" href="<?php echo esc_url( $add_group_url ); ?>"><?php _e( 'New Field Set', 'buddyboss' ); ?></a> <hr class="wp-header-end"> <?php else : ?> <h1> <?php _e( 'Profile Fields', 'buddyboss'); ?> <a id="add_group" class="add-new-h2" href="<?php echo esc_url( $add_group_url ); ?>"><?php _e( 'New Field Set', 'buddyboss' ); ?></a> </h1> <?php endif; ?> <form action="" id="profile-field-form" method="post"> <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); wp_nonce_field( 'bp_reorder_groups', '_wpnonce_reorder_groups', false ); if ( ! empty( $message ) ) : $type = ( $type == 'error' ) ? 'error' : 'updated'; ?> <div id="message" class="<?php echo $type; ?> fade"> <p><?php echo esc_html( $message ); ?></p> </div> <?php endif; ?> <div id="tabs" aria-live="polite" aria-atomic="true" aria-relevant="all"> <ul id="field-group-tabs"> <?php if ( !empty( $groups ) ) : foreach ( $groups as $group ) : ?> <li id="group_<?php echo esc_attr( $group->id ); ?>"> <a href="#tabs-<?php echo esc_attr( $group->id ); ?>" class="ui-tab"> <?php /** This filter is documented in bp-xprofile/bp-xprofile-template.php */ echo esc_html( apply_filters( 'bp_get_the_profile_group_name', $group->name ) ); ?> <?php if ( !$group->can_delete ) : ?> <span><?php _e( '(Signup)', 'buddyboss'); ?></span> <?php endif; ?> </a> </li> <?php endforeach; endif; ?> </ul> <?php if ( !empty( $groups ) ) : foreach ( $groups as $group ) : // Add Field to Group URL $add_field_url = add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'add_field', 'group_id' => (int) $group->id ), $url ); // Edit Group URL $edit_group_url = add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'edit_group', 'group_id' => (int) $group->id ), $url ); // Delete Group URL $delete_group_url = wp_nonce_url( add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'delete_group', 'group_id' => (int) $group->id ), $url ), 'bp_xprofile_delete_group' ); ?> <noscript> <h3><?php /** This filter is documented in bp-xprofile/bp-xprofile-template.php */ echo esc_html( apply_filters( 'bp_get_the_profile_group_name', $group->name ) ); ?></h3> </noscript> <div id="tabs-<?php echo esc_attr( $group->id ); ?>" class="tab-wrapper"> <div class="tab-toolbar"> <div class="tab-toolbar-left"> <a class="button-primary" href="<?php echo esc_url( $add_field_url ); ?>"><?php _e( 'Add New Field', 'buddyboss' ); ?></a> <a class="button edit" href="<?php echo esc_url( $edit_group_url ); ?>"><?php _e( 'Edit Field Set', 'buddyboss' ); ?></a> <?php if ( $group->can_delete ) : ?> <div class="delete-button"> <a class="confirm submitdelete deletion ajax-option-delete delete-profile-field-group" href="<?php echo esc_url( $delete_group_url ); ?>"><?php _e( 'Delete Field Set', 'buddyboss' ); ?></a> </div> <?php endif; ?> <?php /** * Fires at end of action buttons in xprofile management admin. * * @since BuddyPress 2.2.0 * * @param BP_XProfile_Group $group BP_XProfile_Group object * for the current group. */ do_action( 'xprofile_admin_group_action', $group ); ?> </div> </div> <fieldset id="<?php echo esc_attr( $group->id ); ?>" class="connectedSortable field-group" aria-live="polite" aria-atomic="true" aria-relevant="all"> <?php if ( ! empty( $group->description ) ) : ?> <p class="bp-profile-group-description"><?php /** This filter is documented in bp-xprofile/bp-xprofile-template.php */ echo esc_html( apply_filters( 'bp_get_the_profile_group_description', $group->description ) ); ?></p> <?php endif; ?> <legend class="screen-reader-text"><?php /** This filter is documented in bp-xprofile/bp-xprofile-template.php */ /* translators: accessibility text */ printf( esc_html__( 'Fields for "%s" Field Set', 'buddyboss' ), apply_filters( 'bp_get_the_profile_group_name', $group->name ) ); ?></legend> <?php if ( !empty( $group->fields ) ) : foreach ( $group->fields as $field ) { // Load the field. $field = xprofile_get_field( $field->id ); $class = ''; if ( empty( $field->can_delete ) ) { $class = ' core nodrag'; } /** * This function handles the WYSIWYG profile field * display for the xprofile admin setup screen. */ xprofile_admin_field( $field, $group, $class ); } // end for else : // !$group->fields ?> <p class="nodrag nofields"><?php _e( 'There are no fields in this field set.', 'buddyboss' ); ?></p> <?php endif; // End $group->fields. ?> </fieldset> <?php if ( empty( $group->can_delete ) ) : ?> <p><?php esc_html_e( '* These fields appear on the signup page. The (Signup) fields cannot be deleted or moved, as they are needed for the signup process.', 'buddyboss' ); ?></p> <?php endif; ?> </div> <?php endforeach; else : ?> <div id="message" class="error"><p><?php _e( 'You have no field sets.', 'buddyboss' ); ?></p></div> <p><a href="<?php echo esc_url( $add_group_url ); ?>"><?php _e( 'New Field Set', 'buddyboss' ); ?></a></p> <?php endif; ?> </div> </form> </div> <?php }
Changelog
Version | Description |
---|---|
BuddyPress 2.3.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.