Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove role from sso field defaults #2280

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: move role list generation into the admin ui generation
  • Loading branch information
squigglybob committed Nov 27, 2023
commit e44ea4b5e01d8e0e0ddab5b39bfbcf8d2e0d4b42
16 changes: 15 additions & 1 deletion dt-core/admin/menu/tabs/tab-sso-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,21 @@ public function tab( $args ) {
</tr>
<?php
break;
case 'role':
case 'select':

$options = [];
if ( $args['type'] === 'role' ) {
$roles = function_exists( 'dt_list_roles' ) ? dt_list_roles() : [ 'multiplier' => [ 'label' => 'Multiplier', 'disabled' => false ] ];

foreach ( $roles as $role_key => $role ) {
if ( $role['disabled'] === false ) {
$options[$role_key] = $role['label'];
}
}
} else {
$options = $args['default'];
}
?>
<tr>
<td style="width:10%; white-space:nowrap;">
Expand All @@ -174,7 +188,7 @@ public function tab( $args ) {
>
<option></option>
<?php
foreach ( $args['default'] as $item_key => $item_value ) {
foreach ( $options as $item_key => $item_value ) {
?>
<option value="<?php echo esc_attr( $item_key ) ?>" <?php echo ( $item_key === $args['value'] ) ? 'selected' : '' ?>><?php echo esc_html( $item_value ) ?></option>
<?php
Expand Down
12 changes: 1 addition & 11 deletions dt-login/login-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,6 @@ private static function merge_site_and_multisite_vars( $site_fields, $multisite_
}

private static function get_defaults() {
$roles = function_exists( 'dt_list_roles' ) ? dt_list_roles() : [ 'multiplier' => [ 'label' => 'Multiplier', 'disabled' => false ] ];

$role_list = [];
foreach ( $roles as $role_key => $role ) {
if ( $role['disabled'] === false ) {
$role_list[$role_key] = $role['label'];
}
}

$defaults = [
// firebase
'firebase_config_label' => [
Expand Down Expand Up @@ -394,8 +385,7 @@ private static function get_defaults() {
'label' => 'Default Role',
'description' => 'The default role to give a newly registered user',
'value' => 'multiplier',
'type' => 'select',
'default' => $role_list,
'type' => 'role',
'multisite_level' => false,
],

Expand Down