xprofile_admin( string $message = '', string $type = 'error' )

Handles all actions for the admin area for creating, editing and deleting profile groups and fields.


Parameters Parameters

$message

(string) (Optional) Message to display.

Default value: ''

$type

(string) (Optional) Type of action to be displayed.

Default value: 'error'


Source Source

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

function xprofile_admin( $message = '', $type = 'error' ) {

	// What mode?
	$mode = ! empty( $_GET['mode'] )
		? sanitize_key( $_GET['mode'] )
		: false;

	// Group ID.
	$group_id = ! empty( $_GET['group_id'] )
		? intval( $_GET['group_id'] )
		: false;

	// Field ID.
	$field_id = ! empty( $_GET['field_id'] )
		? intval( $_GET['field_id'] )
		: false;

	// Option ID.
	$option_id = ! empty( $_GET['option_id'] )
		? intval( $_GET['option_id'] )
		: false;

	// Allowed modes.
	$allowed_modes = array(
		'add_group',
		'edit_group',
		'delete_group',
		'do_delete_group',
		'add_field',
		'edit_field',
		'delete_field',
		'do_delete_field',
		'delete_option',
		'do_delete_option'
	);

	// Is an allowed mode.
	if ( in_array( $mode, $allowed_modes, true ) ) {

		// All group actions.
		if ( false !== $group_id ) {

			// Add field to group.
			if ( 'add_field' == $mode ) {
				xprofile_admin_manage_field( $group_id );

			// Edit field of group.
			} elseif ( ! empty( $field_id ) && 'edit_field' === $mode ) {
				xprofile_admin_manage_field( $group_id, $field_id );

			// Delete group.
			} elseif ( in_array( $mode, array( 'delete_group', 'do_delete_group' ), true ) ) {
				xprofile_admin_delete_group( $group_id );

			// Edit group.
			} elseif ( 'edit_group' === $mode ) {
				xprofile_admin_manage_group( $group_id );
			}

		// Delete field.
		} elseif ( ( false !== $field_id ) && ( in_array( $mode, array( 'delete_field', 'do_delete_field' ), true ) ) ) {
			xprofile_admin_delete_field( $field_id, 'field' );

		// Delete option.
		} elseif ( ! empty( $option_id ) && in_array( $mode, array( 'delete_option', 'do_delete_option' ), true ) ) {
			xprofile_admin_delete_field( $option_id, 'option' );

		// Add group.
		} elseif ( 'add_group' == $mode ) {
			xprofile_admin_manage_group();
		}

	} else {
		xprofile_admin_screen( $message, $type );
	}
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.