Action: um_role_edit_data

do_action( 'um_role_edit_data', $data, $id, $update )

Filters the role meta before save it to DB.

Parameters:
Name Type Description
$data array

Role meta.

$id string

Role key.

$update bool

Create or update role. "True" if update.

Since:
  • 2.6.3
Source:
Examples

Add custom metadata for role on saving.

function my_custom_um_role_edit_data( $data, $id, $update ) {
    $data['{meta_key}'] = {meta_value}; // set your meta key and meta value
    return $data;
}
add_action( 'um_role_edit_data', 'my_custom_um_role_edit_data', 10, 3 );

Force remove role's metadata on saving when update.

function my_custom_um_role_edit_data( $data, $id, $update ) {
    if ( true === $update ) {
        unset( $data['{meta_key}'] ); // set your meta key
    }
    return $data;
}
add_action( 'um_role_edit_data', 'my_custom_um_role_edit_data', 10, 3 );