um_admin_role_metaboxes

Hook type

Filter

Description

Extend metaboxes at Add/Edit User Role

Parameters

$roles_metaboxes

(array) Metaboxes at Add/Edit UM Role

Usage

add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 );

Example

Code

add_filter( 'um_admin_role_metaboxes', 'my_admin_role_metaboxes', 10, 1 );

function my_admin_role_metaboxes( $roles_metaboxes ) {
	$roles_metaboxes[] = array(
		'id'       => 'um-admin-form-my-metabox',
		'title'    => __( 'My Metabox', 'ultimate-member' ),
		'callback' => 'my_metabox_callback',
		'screen'   => 'um_role_meta',
		'context'  => 'normal',
		'priority' => 'default',
	);
	return $roles_metaboxes;
}

function my_metabox_callback( $object = array() ) {
	$role = $object['data'];
	?>
	<div class="um-admin-metabox">
		<?php
		UM()->admin_forms(
			array(
				'class'     => 'um-role-my-metabox um-half-column',
				'prefix_id' => 'role',
				'fields'    => array(
					array(
						'id'      => '_um_custom_url',
						'type'    => 'text',
						'label'   => __( 'Logo URL', 'ultimate-member' ),
						'tooltip' => __( 'Set an url for Logo', 'ultimate-member' ),
						'value'   => empty( $role['_um_custom_url'] ) ? '' : $role['_um_custom_url'],
					)
				)
			)
		)->render_form();
		?>
		<div class="um-admin-clear"></div>
	</div>
	<?php
}

Screenshots

Image - Custom metabox on wp-admin > Ultimate Member > User Roles > Edit Role.

Change Log

Since: 2.0

Source

File includes/admin/core/class-admin-metabox.php | View on GitHub