Skip to content

Commit 51ebc88

Browse files
committed
Fix role names not displaying properly
1 parent 1f4ee5b commit 51ebc88

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

includes/wpum-fields/types/class-wpum-field-userrole.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public function __construct() {
2020
$this->type = 'userrole';
2121
$this->icon = 'dashicons-admin-generic';
2222
$this->group = 'advanced';
23-
$this->allow_default = true;
2423
$this->min_addon_version = '2.5';
2524
}
2625

@@ -81,10 +80,14 @@ function get_formatted_output( $field, $value ) {
8180
$value = array( $value );
8281
}
8382

84-
return implode( ', ', $value );
85-
}
83+
global $wp_roles;
84+
$available_roles = $wp_roles->get_names();
85+
86+
$selected_roles = [];
87+
foreach ( $value as $role ) {
88+
$selected_roles[] = $available_roles[ $role ];
89+
}
8690

87-
public function template() {
88-
return $this->type;
91+
return implode( ', ', $selected_roles );
8992
}
9093
}

0 commit comments

Comments
 (0)