LLMS_Helper_Betas::handle_form_submit()

Handle channel subscription saves


Return Return

(null|string) Returns null when nonce errors or invalid data are submitted, otherwise returns an array of addon subscription data.


Top ↑

Source Source

File: libraries/lifterlms-helper/includes/class-llms-helper-betas.php

	public function handle_form_submit() {

		if ( ! llms_verify_nonce( '_llms_beta_sub_nonce', 'llms_save_channel_subscriptions' ) ) {
			return;
		}

		$subs = llms_filter_input( INPUT_POST, 'llms_channel_subscriptions', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY );
		if ( ! $subs || ! is_array( $subs ) ) {
			return;
		}

		$new_subscription = false;

		foreach ( $subs as $id => $channel ) {

			$addon = llms_get_add_on( $id );
			if ( 'channel' !== $addon->get_channel_subscription() ) {
				$addon->subscribe_to_channel( sanitize_text_field( $channel ) );
				$new_subscription = true;
			}
		}

		// When a channel subscription changes also flush caches so we'll get the most recent add-on data immediately and allow upgrading immediately from wp core update screens.
		if ( $new_subscription ) {
			llms_helper_flush_cache();
		}

		return $subs;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.2.1 Flush transient caches when a subscription changes.
3.2.0 Don't access $_POST directly.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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