LLMS_Rest_Admin_Settings_API_Keys::save_create()
Form handler to create a new API key.
Return Return
(LLMS_REST_API_Key|WP_Error)
Source Source
File: libraries/lifterlms-rest/includes/admin/class-llms-rest-admin-settings-api-keys.php
protected static function save_create() {
$user_id = llms_filter_input( INPUT_POST, 'llms_rest_key_user_id', FILTER_SANITIZE_NUMBER_INT );
$authorized = self::authorize_key_owner( $user_id );
if ( is_wp_error( $authorized ) ) {
return $authorized;
}
$create = LLMS_REST_API()->keys()->create(
array(
'description' => llms_filter_input_sanitize_string( INPUT_POST, 'llms_rest_key_description' ),
'user_id' => $user_id,
'permissions' => llms_filter_input_sanitize_string( INPUT_POST, 'llms_rest_key_permissions' ),
)
);
if ( ! is_wp_error( $create ) ) {
self::$generated_key = $create;
}
return $create;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0-beta.27 | Replaced use of the deprecated FILTER_SANITIZE_STRING constant. |
| 1.0.0-beta.1 | Introduced. |