Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@b55ddf4 from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Feb 27, 2024
1 parent 4a2f9cb commit 513fec8
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
55 changes: 55 additions & 0 deletions includes/user-permissions/class-user-permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,59 @@ public function autoload_user_roles() {
public function enforce_two_factor($value) {
return defined('VIP_GO_APP_ENVIRONMENT') && 'production' === \VIP_GO_APP_ENVIRONMENT;
}

public function register_common_user_meta() {
register_meta(
'user',
'prc_copilot_settings',
array(
'type' => 'object',
'description' => 'Settings for PRC Copilot plugin',
'single' => true,
'show_in_rest' => true,
)
);
register_meta(
'user',
'prc_staff_id',
array(
'type' => 'number',
'description' => 'Links a staff record to a user record',
'single' => true,
'show_in_rest' => true,
)
);
register_meta(
'user',
'prc_staff_benefeciary_id',
array(
'type' => 'number',
'description' => 'When a user is deleted this user is the benefeciary of their db records',
'single' => true,
'show_in_rest' => true,
)
);
}

/**
* Fires after a new user has been registered, checks for the existence of default meta and if none
* sets accordingly.
*
* @hook register_new_user
* @return void
*/
public function set_default_meta_on_new_user_creation() {
$copilot_defaults = array(
'allowed' => true,
'tokenBudget' => 1000,
'allowances' => array(
'excerpt' => true, // Do we allow the user to use the copilot excerpt generation function
'title' => true, // Do we allow the user to use the copilot title generation function
'content' => false, // Do we allow the user to use the copilot content generation function
)
);
if ( ! get_user_meta( $user_id, 'prc_copilot_settings', true ) ) {
add_user_meta( $user_id, 'prc_copilot_settings', $copilot_defaults, true );
}
}
}
16 changes: 16 additions & 0 deletions includes/user-permissions/user-roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@
"wpseo_edit_advanced_metadata": true,
"wpseo_bulk_edit": true
}
},
"comms-editor": {
"name": "Communications Editor",
"inherits": "editor",
"capabilities": {
"wpseo_manage_options": true,
"wpseo_edit_advanced_metadata": true,
"wpseo_bulk_edit": true
}
},
"designer": {
"name": "Designer",
"inherits": "editor",
"capabilities": {
"edit_theme_options": true
}
}
}
}

0 comments on commit 513fec8

Please sign in to comment.