xprofile_admin( string $message = '', string $type = 'error' )
Handles all actions for the admin area for creating, editing and deleting profile groups and fields.
Description
Parameters
- $message
-
(string) (Optional) Message to display.
Default value: ''
- $type
-
(string) (Optional) Type of action to be displayed.
Default value: 'error'
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', 'add_field', 'edit_field', 'delete_field', '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 ( 'delete_group' === $mode ) { xprofile_admin_delete_group( $group_id ); // Edit group } elseif ( 'edit_group' === $mode ) { xprofile_admin_manage_group( $group_id ); } // Delete field } elseif ( ( false !== $field_id ) && ( 'delete_field' === $mode ) ) { xprofile_admin_delete_field( $field_id, 'field'); // Delete option } elseif ( ! empty( $option_id ) && 'delete_option' === $mode ) { xprofile_admin_delete_field( $option_id, 'option' ); // Add group } elseif ( 'add_group' == $mode ) { xprofile_admin_manage_group(); } } else { xprofile_admin_screen( $message, $type ); } }
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.