BP_XProfile_Group::render_admin_form()

Output the admin area field group form.

Description

Source

File: bp-xprofile/classes/class-bp-xprofile-group.php

	public function render_admin_form() {
		global $message;

		// Users Admin URL
		$users_url = bp_get_admin_url( 'admin.php' );

		// URL to cancel to
		$cancel_url = add_query_arg( array(
			'page' => 'bp-profile-setup'
		), $users_url );

		// New field group.
		if ( empty( $this->id ) ) {
			$title	= __( 'New Field Set', 'buddyboss' );
			$button	= __( 'Save',                'buddyboss' );
			$action	= add_query_arg( array(
				'page' => 'bp-profile-setup',
				'mode' => 'add_group'
			), $users_url );

		// Existing field group.
		} else {
			$title  = __( 'Edit Field Set', 'buddyboss' );
			$button	= __( 'Update',           'buddyboss' );
			$action	= add_query_arg( array(
				'page'     => 'bp-profile-setup',
				'mode'     => 'edit_group',
				'group_id' => (int) $this->id
			), $users_url );
		} ?>

		<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><?php echo esc_html( $title ); ?></h1>

			<?php if ( ! empty( $message ) ) : ?>

				<div id="message" class="error fade">
					<p><?php echo esc_html( $message ); ?></p>
				</div>

			<?php endif; ?>

			<form id="bp-xprofile-add-field-group" 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">
							<div id="titlediv">
								<div class="titlewrap">
									<label id="title-prompt-text" for="title"><?php esc_html_e( 'Field Set Name (required)', 'buddyboss') ?></label>
									<input type="text" name="group_name" id="title" value="<?php echo esc_attr( $this->name ); ?>" autocomplete="off" />
								</div>
							</div>
							<div class="postbox">
								<h2><?php esc_html_e( 'Field Set Description', 'buddyboss' ); ?></h2>
								<div class="inside">
									<label for="group_description" class="screen-reader-text"><?php
										/* translators: accessibility text */
										esc_html_e( 'Add description', 'buddyboss' );
									?></label>
									<textarea name="group_description" id="group_description" rows="8" cols="60"><?php echo esc_textarea( $this->description ); ?></textarea>
								</div>
							</div>

							<?php

							/**
							 * Fires after the XProfile group description field is rendered in wp-admin.
							 *
							 * @since BuddyPress 2.6.0
							 *
							 * @param BP_XProfile_Group $this Current XProfile group.
							 */
							do_action( 'xprofile_group_admin_after_description', $this ); ?>

						</div><!-- #post-body-content -->

						<div id="postbox-container-1" class="postbox-container">

							<?php

							/**
							 * Fires before XProfile Group submit metabox.
							 *
							 * @since BuddyPress 2.1.0
							 *
							 * @param BP_XProfile_Group $this Current XProfile group.
							 */
							do_action( 'xprofile_group_before_submitbox', $this ); ?>

							<div id="submitdiv" class="postbox">
								<h2><?php _e( 'Submit', 'buddyboss' ); ?></h2>
								<div class="inside">
									<div id="submitcomment" class="submitbox">
										<div id="major-publishing-actions">

											<?php

											// Nonce fields
											wp_nonce_field( 'bp_xprofile_admin_group', 'bp_xprofile_admin_group' );

											/**
											 * Fires at the beginning of the XProfile Group publishing actions section.
											 *
											 * @since BuddyPress 2.1.0
											 *
											 * @param BP_XProfile_Group $this Current XProfile group.
											 */
											do_action( 'xprofile_group_submitbox_start', $this ); ?>

											<input type="hidden" name="group_order" id="group_order" value="<?php echo esc_attr( $this->group_order ); ?>" />
											<div id="publishing-action">
												<input type="submit" name="save_group" value="<?php echo esc_attr( $button ); ?>" class="button-primary"/>
											</div>
											<div id="delete-action">
												<a href="<?php echo esc_url( $cancel_url ); ?>" class="deletion"><?php _e( 'Cancel', 'buddyboss' ); ?></a>
											</div>
											<div class="clear"></div>
										</div>
									</div>
								</div>
							</div>

							<?php

							/**
							 * Fires after XProfile Group submit metabox.
							 *
							 * @since BuddyPress 2.1.0
							 *
							 * @param BP_XProfile_Group $this Current XProfile group.
							 */
							do_action( 'xprofile_group_after_submitbox', $this ); ?>

                            <?php
                            /**
                             * The main profile field group, used in registration form,
                             * can not be a repeater.
                             */
                            if ( empty( $this->id ) || $this->can_delete ) : ?>

                                <?php $enabled = 'on' == self::get_group_meta( $this->id, 'is_repeater_enabled' ) ? 'on' : 'off'; ?>

                                <div id="repeatersetdiv" class="postbox">
                                    <h2><?php _e( 'Repeater Set', 'buddyboss' ); ?></h2>
                                    <div class="inside">
                                    	<p style="margin-top: 0;"><?php _e( 'Allow the profile fields within this set to be repeated again and again, so the user can add multiple instances of their data.', 'buddyboss' );?></p>
                                		<select name="group_is_repeater" id="group_is_repeater" >
                                            <option value="off" <?php selected( $enabled, 'off' );?>><?php _e( 'Disabled', 'buddyboss' );?></option>
                                            <option value="on" <?php selected( $enabled, 'on' );?>><?php _e( 'Enabled', 'buddyboss' );?></option>
                                        </select>
                                    </div>
                                </div>

                            <?php endif; ?>

						</div>
					</div>
				</div>
			</form>
		</div>

	<?php
	}

Changelog

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