Paid_Memberships_Pro_Helpers::all_memberships( null $label = null, string $option_code = 'PMPMEMBERSHIP' )


Parameters Parameters

$label

(null) (Optional)

Default value: null

$option_code

(string) (Optional)

Default value: 'PMPMEMBERSHIP'


Top ↑

Return Return

(mixed|void)


Source Source

File: src/integrations/paid-memberships-pro/helpers/paid-memberships-pro-helpers.php

	public function all_memberships( $label = null, $option_code = 'PMPMEMBERSHIP' ) {
		if ( ! $this->load_options ) {


			return Automator()->helpers->recipe->build_default_options_array( $label, $option_code );
		}

		if ( ! $label ) {
			$label = esc_attr__( 'Membership', 'uncanny-automator' );
		}

		global $wpdb;
		$qry     = "SELECT * FROM $wpdb->pmpro_membership_levels ORDER BY id ASC";
		$levels  = $wpdb->get_results( $qry );
		$options = array();
		if ( $levels ) {
			$options['-1'] = esc_attr__( 'Any membership', 'uncanny-automator' );
			foreach ( $levels as $level ) {
				$options[ $level->id ] = $level->name;
			}
		}
		$option = [
			'option_code'     => $option_code,
			'label'           => $label,
			'input_type'      => 'select',
			'required'        => true,
			'options'         => $options,
			'relevant_tokens' => [
				$option_code         => esc_attr__( 'Membership title', 'uncanny-automator' ),
				$option_code . '_ID' => esc_attr__( 'Membership ID', 'uncanny-automator' ),
				//$option_code . '_URL' =>  esc_attr__( 'Product URL', 'uncanny-automator' ),
			],
		];

		return apply_filters( 'uap_option_all_pmp_memberships', $option );
	}