本文整理汇总了PHP中MS_Model_Membership::get_guest方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Model_Membership::get_guest方法的具体用法?PHP MS_Model_Membership::get_guest怎么用?PHP MS_Model_Membership::get_guest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Model_Membership
的用法示例。
在下文中一共展示了MS_Model_Membership::get_guest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare_fields
/**
* Prepare the fields displayed in the form.
*
* @since 1.0.0
* @return array
*/
public function prepare_fields()
{
$membership = $this->data['membership'];
$fields = array('type' => array('id' => 'type', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO, 'value' => $membership->type ? $membership->type : MS_Model_Membership::TYPE_STANDARD, 'class' => 'ms-choose-type', 'field_options' => array(MS_Model_Membership::TYPE_STANDARD => array('text' => __('Standard Membership', MS_TEXT_DOMAIN), 'desc' => __('Make your content available to Members and hidden to Guests (logged-out users).', MS_TEXT_DOMAIN)), MS_Model_Membership::TYPE_DRIPPED => array('text' => __('Dripped Content Membership.', MS_TEXT_DOMAIN), 'desc' => __('Set-up membership content to be released / made available in intervals.', MS_TEXT_DOMAIN)), MS_Model_Membership::TYPE_GUEST => array('text' => __('Guest Membership', MS_TEXT_DOMAIN), 'desc' => __('Make your content available only to Guests (logged-out users).', MS_TEXT_DOMAIN)), MS_Model_Membership::TYPE_USER => array('text' => __('Default Membership', MS_TEXT_DOMAIN), 'desc' => __('Content is available to all logged-in users that did not join any other Membership yet.', MS_TEXT_DOMAIN)))), 'name' => array('id' => 'name', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => __('Name Your Membership:', MS_TEXT_DOMAIN), 'value' => $membership->name, 'class' => 'ms-text-large', 'placeholder' => __('Choose a name that will identify this membership...', MS_TEXT_DOMAIN), 'label_type' => 'h3'), 'config_fields' => array('public' => array('id' => 'public', 'type' => MS_Helper_Html::INPUT_TYPE_CHECKBOX, 'title' => __('Allow users to register for this membership.', MS_TEXT_DOMAIN), 'desc' => __('If selected, registration experience will be added to your site. Do not tick if you want to make this a private membership.', MS_TEXT_DOMAIN), 'after' => sprintf('<span class="locked-info">%1$s</span>', __('Not available for the Guest Membership', MS_TEXT_DOMAIN)), 'value' => !$membership->private), 'public_flag' => array('id' => 'set_public_flag', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 1), 'paid' => array('id' => 'paid', 'type' => MS_Helper_Html::INPUT_TYPE_CHECKBOX, 'title' => __('This is a paid membership.', MS_TEXT_DOMAIN), 'desc' => __('Choose this if you want to receive payments from members via Payment Gateways.', MS_TEXT_DOMAIN), 'after' => sprintf('<span class="locked-info">%1$s</span>', __('Not available for the Guest Membership', MS_TEXT_DOMAIN)), 'value' => !$membership->is_free()), 'paid_flag' => array('id' => 'set_paid_flag', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 1)), 'control_fields' => array('membership_id' => array('id' => 'membership_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership->id), 'step' => array('id' => 'step', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $this->data['step']), 'action' => array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $this->data['action']), '_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($this->data['action'])), 'cancel' => array('id' => 'cancel', 'type' => MS_Helper_Html::INPUT_TYPE_BUTTON, 'value' => __('Cancel', MS_TEXT_DOMAIN), 'data_ms' => array('action' => MS_Controller_Settings::AJAX_ACTION_UPDATE_SETTING, 'field' => 'initial_setup', 'value' => '0')), 'save' => array('id' => 'save', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save and continue', MS_TEXT_DOMAIN) . ' »')));
// Only one Guest Membership can be added
if (MS_Model_Membership::get_guest()->is_valid()) {
unset($fields['type']['field_options'][MS_Model_Membership::TYPE_GUEST]);
}
// Only one User Membership can be added
if (MS_Model_Membership::get_user()->is_valid()) {
unset($fields['type']['field_options'][MS_Model_Membership::TYPE_USER]);
}
// Wizard can only be cancelled when at least one membership exists in DB.
$count = MS_Model_Membership::get_membership_count();
if (!$count) {
unset($fields['control_fields']['cancel']);
}
return $fields;
}
示例2: init_member
/**
* Initialise current member.
*
* Get current member and membership relationships.
* If user is not logged in (visitor), assign a visitor membership.
* If user is logged in but has not any memberships, assign a default membership.
* Deactivated users (active == false) get visitor membership assigned.
*
* @since 1.0.0
*/
public function init_member()
{
do_action('ms_load_member', $this);
$this->member = MS_Model_Member::get_current_member();
if (MS_Plugin::is_enabled()) {
if (!is_user_logged_in()) {
// If a Guest-Membership exists we also assign it to the user.
$ms_guest = MS_Model_Membership::get_guest();
if ($ms_guest->is_valid() && $ms_guest->active) {
$this->member->add_membership($ms_guest->id);
}
} elseif (!$this->member->has_membership()) {
// Apply User-Membership to logged-in users without subscriptions.
$ms_user = MS_Model_Membership::get_user();
if ($ms_user->is_valid() && $ms_user->active) {
$this->member->add_membership($ms_user->id);
}
} elseif (!$this->member->is_member) {
$this->member->subscriptions = array();
}
// No subscription: Assign the base membership, which only denies access.
if (!$this->member->has_membership()) {
$this->member->add_membership(MS_Model_Membership::get_base()->id);
}
}
/**
* At this point the plugin is initialized and we are here:
* - All Add-Ons are registered
* - All Rules are registered
* - Know the current User
* - All Subscriptions/Memberships of the user are loaded
* - System memberships are already assigned (guest/base)
* - Payment gateways are registered
* - Communication settings are loaded
*
* Next we tell everybody that we are ready to get serious!
*
* What happens next:
* 1. All Membership-Rules are initialized/merged
* 2. Front-End Protection is applied
* 3. Admin-Side Protection is applied
*/
do_action('ms_init_done', $this);
}