LLMS_Rest_Admin_Settings_API_Keys::save_create()

Form handler to create a new API key.


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

	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;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.27 Replaced use of the deprecated FILTER_SANITIZE_STRING constant.
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.