我使用插件付費會員訂閱在我的WP網站。如何設置默認所有檢查的一些選擇在PHP
我應該添加什麼代碼下面的腳本:
<div class="pms-meta-box-field-wrapper">
<label class="pms-meta-box-field-label"><?php _e('Subscription Plans', 'paid-member-subscriptions'); ?></label>
<?php
$subscription_plans = pms_get_subscription_plans();
$selected_subscription_plans = get_post_meta($post->ID, 'pms-content-restrict-subscription-plan');
?>
<?php if(!empty($subscription_plans)): foreach($subscription_plans as $subscription_plan): ?>
<label class="pms-meta-box-checkbox-label" for="pms-content-restrict-subscription-plan-<?php echo $subscription_plan->id ?>">
<input type="checkbox" value="<?php echo $subscription_plan->id; ?>" <?php if(in_array($subscription_plan->id, $selected_subscription_plans)) echo 'checked="checked"'; ?> name="pms-content-restrict-subscription-plan[]" id="pms-content-restrict-subscription-plan-<?php echo $subscription_plan->id ?>">
<?php echo $subscription_plan->name; ?>
</label>
<?php endforeach; ?>
<p class="description"><?php echo __('Members subscribed to these Subscription plans will be able to view this page.', 'paid-member-subscriptions'); ?></p>
<?php else: ?>
<p class="description"><?php printf(__('You do not have any active Subscription Plans yet. Please create them <a href="%s">here</a>', 'paid-member-subscriptions'), admin_url('edit.php?post_type=pms-subscription')); ?></p>
<?php endif; ?>
</div>
(source: .../wp-content/plugins/paid-member-subscriptions/includes/admin/meta-boxes/views/view-meta-box-single-content-restriction.php)
感謝,我的問題得到解決。 –