BP_XProfile_Field::render_admin_form( string $message = '', string $message_type = 'error' )
Output the admin form for this field.
Description
Parameters
- $message
-
(Optional) Message to display.
Default value: ''
- $message_type
-
(Optional) error or udpated
Default value: 'error'
Source
File: bp-xprofile/classes/class-bp-xprofile-field.php
public function render_admin_form( $message = '', $message_type = 'error' ) {
// Users Admin URL
$users_url = bp_get_admin_url( 'admin.php' );
// Add New
if ( empty( $this->id ) ) {
$title = __( 'Add New Field', 'buddyboss' );
$button = __( 'Save', 'buddyboss' );
$action = add_query_arg( array(
'page' => 'bp-profile-setup',
'mode' => 'add_field',
'group_id' => (int) $this->group_id
), $users_url . '#tabs-' . (int) $this->group_id );
if ( ! empty( $_POST['saveField'] ) ) {
$this->name = $_POST['title'];
$this->description = $_POST['description'];
$this->is_required = $_POST['required'];
$this->type = $_POST['fieldtype'];
$this->field_order = $_POST['field_order'];
if ( ! empty( $_POST["sort_order_{$this->type}"] ) ) {
$this->order_by = $_POST["sort_order_{$this->type}"];
}
}
// Edit
} else {
$title = __( 'Edit Field', 'buddyboss' );
$button = __( 'Update', 'buddyboss' );
$action = add_query_arg( array(
'page' => 'bp-profile-setup',
'mode' => 'edit_field',
'group_id' => (int) $this->group_id,
'field_id' => (int) $this->id
), $users_url . '#tabs-' . (int) $this->group_id );
} ?>
<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
}
?>
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
<?php
if ( $this->id ) {
$action_add = add_query_arg( array(
'page' => 'bp-profile-setup',
'mode' => 'add_field',
'group_id' => (int) $this->group_id
), $users_url . '#tabs-' . (int) $this->group_id );
?>
<a href="<?php echo esc_url( $action_add ); ?>"
class="page-title-action"><?php esc_html_e( 'Add New Field', 'buddyboss' ); ?></a>
<?php
}
?>
<?php if ( ( ! empty( $message ) ) || ( isset( $_GET['type'] ) && 'updated' === $_GET['type'] ) ) : ?>
<?php
if ( isset( $_GET['type'] ) && 'updated' === $_GET['type'] ) {
$message = __( 'The field was saved successfully.', 'buddyboss' );
$message_type = 'updated';
} ?>
<div id="message" class="<?php echo $message_type; ?> fade">
<p><?php echo esc_html( $message ); ?></p>
</div>
<?php endif; ?>
<form id="bp-xprofile-add-field" action="<?php echo esc_url( $action ); ?>" method="post">
<div id="poststuff">
<div id="post-body"
class="metabox-holder columns-<?php echo ( 1 == get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
<div id="post-body-content">
<?php
// Output the name & description fields.
$this->name_and_description(); ?>
</div><!-- #post-body-content -->
<div id="postbox-container-1" class="postbox-container">
<?php
// Output the sumbit metabox.
$this->submit_metabox( $button );
// Output the required metabox.
$this->required_metabox();
// Output the profile types metabox.
$this->member_type_metabox();
// Output the field visibility metaboxes.
$this->visibility_metabox();
/**
* Fires after XProfile Field sidebar metabox.
*
* @since BuddyPress 2.2.0
*
* @param BP_XProfile_Field $this Current XProfile field.
*/
do_action( 'xprofile_field_after_sidebarbox', $this ); ?>
</div>
<div id="postbox-container-2" class="postbox-container">
<?php
/**
* Fires before XProfile Field content metabox.
*
* @since BuddyPress 2.3.0
*
* @param BP_XProfile_Field $this Current XProfile field.
*/
do_action( 'xprofile_field_before_contentbox', $this );
// Output the field attributes metabox.
$this->type_metabox();
// Output hidden inputs for default field.
$this->default_field_hidden_inputs();
/**
* Fires after XProfile Field content metabox.
*
* @since BuddyPress 2.2.0
*
* @param BP_XProfile_Field $this Current XProfile field.
*/
do_action( 'xprofile_field_after_contentbox', $this ); ?>
</div>
</div><!-- #post-body -->
</div><!-- #poststuff -->
</form>
</div>
<?php
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.9.0 | BuddyPress 1.9.0 |
| BuddyBoss 1.0.0 Added the paramter $message_type | 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.