LLMS_REST_Posts_Controller::handle_featured_media( int $featured_media, int $object_id )

Determines the featured media based on a request param

Description Description

Heavily based on WP_REST_Posts_Controller::handle_featured_media().

Top ↑

Parameters Parameters


(int) (Required) Featured Media ID.


(int) (Required) LLMS object ID.

Top ↑

Return Return

(bool|WP_Error) Whether the post thumbnail was successfully deleted, otherwise WP_Error.

Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-posts-controller.php

	protected function handle_featured_media( $featured_media, $object_id ) {

		$featured_media = (int) $featured_media;
		if ( $featured_media ) {
			$result = set_post_thumbnail( $object_id, $featured_media );
			if ( $result ) {
				return true;
			} else {
				return llms_rest_bad_request_error( __( 'Invalid featured media ID.', 'lifterlms' ) );
		} else {
			return delete_post_thumbnail( $object_id );


Top ↑

Changelog Changelog

Version Description
1.0.0-beta.18 Fixed call to undefined function llms_bad_request_error(), must be llms_rest_bad_request_error().
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.