LLMS_Template_Loader::restricted_by_membership( array $info )

Handle content restricted to a membership.


Description Description

Parses and obeys Membership "Restriction Behavior" settings.


Top ↑

Parameters Parameters

$info

(array) (Required) Array of restriction info from llms_page_restricted().


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.template.loader.php

	 * @return void
	 */
	public function restricted_by_membership( $info ) {

		$membership_id = $info['restriction_id'];

		// Do nothing if we don't have a membership id.
		if ( ! empty( $membership_id ) && is_numeric( $membership_id ) ) {

			// Instantiate the membership.
			$membership = new LLMS_Membership( $membership_id );

			$msg      = '';
			$redirect = '';

			if ( 'yes' === $membership->get( 'restriction_add_notice' ) ) {

				$msg = $membership->get( 'restriction_notice' );

			}

			// Get the redirect based on the redirect type (if set).
			switch ( $membership->get( 'restriction_redirect_type' ) ) {

				case 'custom':
					$redirect = $membership->get( 'redirect_custom_url' );
					break;

				case 'membership':
					$redirect = get_permalink( $membership->get( 'id' ) );
					break;

				case 'page':
					$redirect = get_permalink( $membership->get( 'redirect_page_id' ) );
					// Make sure to print notices in wp pages.
					$redirect = empty( $msg ) ? $redirect : add_query_arg(
						array(
							'llms_print_notices' => 1,
						),
						$redirect
					);
					break;

			}

			// Handle the restriction action & allow developers to filter the results.
			$this->handle_restriction(
				apply_filters( 'llms_restricted_by_membership_message', $msg, $info ),
				apply_filters( 'llms_restricted_by_membership_redirect', $redirect, $info )
			);

		}


Top ↑

Changelog Changelog

Changelog
Version Description
3.37.10 Added Flag to print notices when landing on the redirected page.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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