LLMS_REST_API_Keys_Controller::create_item( WP_REST_Request $request )

Create an API Key


Parameters Parameters

$request

(WP_REST_Request) (Required) Request object.


Top ↑

Return Return

(WP_Error|WP_REST_Response)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/server/class-llms-rest-api-keys-controller.php

	public function create_item( $request ) {

		$prepared = $this->prepare_item_for_database( $request );
		$key      = LLMS_REST_API()->keys()->create( $prepared );
		if ( is_wp_error( $request ) ) {
			$request->add_data( array( 'status' => 400 ) );
			return $request;
		}

		$response = $this->prepare_item_for_response( $key, $request );
		$response->set_status( 201 );
		$response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $key->get( 'id' ) ) ) );

		return $response;

	}


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.