LLMS_Rest_Admin_Settings_API_Keys::save_update( int $key_id )

Form handler to save an API key.


Parameters Parameters

$key_id

(int) (Required) API Key ID.


Top ↑

Return Return

(LLMS_REST_API_Key|WP_Error)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/admin/class-llms-rest-admin-settings-api-keys.php

289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
* @return LLMS_REST_API_Key|WP_Error
 */
protected static function save_update( $key_id ) {
 
    $key = LLMS_REST_API()->keys()->get( $key_id );
    if ( ! $key ) {
        // Translators: %s = Invalid API Key ID.
        return new WP_Error( 'llms_rest_api_key_not_found', sprintf( __( '"%s" is not a valid API Key.', 'lifterlms' ), $key_id ) );
    }
 
    $update = LLMS_REST_API()->keys()->update(
        array(
            'id'          => $key_id,
            'description' => llms_filter_input_sanitize_string( INPUT_POST, 'llms_rest_key_description' ),
            'user_id'     => llms_filter_input( INPUT_POST, 'llms_rest_key_user_id', FILTER_SANITIZE_NUMBER_INT ),
            'permissions' => llms_filter_input_sanitize_string( INPUT_POST, 'llms_rest_key_permissions' ),
        )
    );
 
    return $update;


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.