<?php $links = array(array('id' => 'settings', 'title' => __('Memberful'), 'url' => memberful_wp_plugin_settings_url()), array('id' => 'bulk_protect', 'title' => __('Bulk restrict access tool'), 'url' => memberful_wp_plugin_bulk_protect_url()), array('id' => 'advanced_settings', 'title' => __('Advanced Role Mapping'), 'url' => memberful_wp_plugin_advanced_settings_url()), array('id' => 'private_user_feed_settings', 'title' => __('Private RSS Feeds'), 'url' => memberful_wp_plugin_private_user_feed_settings_url())); if (is_plugin_active('bbpress/bbpress.php')) { $links[] = array('id' => 'protect_bbpress', 'title' => __('bbPress Forums'), 'url' => memberful_wp_plugin_protect_bbpress_url()); } ?> <h2 class="nav-tab-wrapper"> <?php foreach ($links as $link) { ?> <a href="<?php echo $link['url']; ?> " id="nav_tab_<?php echo $link['id']; ?> " class="nav-tab <?php echo $link['id'] === $active ? 'nav-tab-active' : ''; ?> "><?php echo $link['title']; ?> </a> <?php } ?> </h2>
function memberful_wp_advanced_settings() { $allowed_roles = memberful_wp_roles_that_can_be_mapped_to(); $current_active_role = memberful_wp_role_for_active_customer(); $current_inactive_role = memberful_wp_role_for_inactive_customer(); if (!empty($_POST)) { $new_active_role = isset($_POST['role_mappings']['active_customer']) ? $_POST['role_mappings']['active_customer'] : ''; $new_inactive_role = isset($_POST['role_mappings']['inactive_customer']) ? $_POST['role_mappings']['inactive_customer'] : ''; if (array_key_exists($new_active_role, $allowed_roles) && array_key_exists($new_inactive_role, $allowed_roles)) { update_option('memberful_role_active_customer', $new_active_role); update_option('memberful_role_inactive_customer', $new_inactive_role); memberful_wp_update_customer_roles($current_active_role, $new_active_role, $current_inactive_role, $new_inactive_role); Memberful_Wp_Reporting::report(__('Settings updated')); } else { Memberful_Wp_Reporting::report(__('The roles you chose aren\'t in the list of allowed roles'), 'error'); } wp_redirect(memberful_wp_plugin_advanced_settings_url()); } $vars = array('available_state_mappings' => array('active_customer' => array('name' => 'Any active subscription plans', 'current_role' => $current_active_role), 'inactive_customer' => array('name' => 'No active subscription plans', 'current_role' => $current_inactive_role)), 'available_roles' => $allowed_roles); memberful_wp_render('advanced_settings', $vars); }
<div class="wrap"> <?php memberful_wp_render('option_tabs', array('active' => 'advanced_settings')); ?> <?php memberful_wp_render('flash'); ?> <p><?php _e("Assign roles to active (paying) and inactive (not paying) members. Memberful will automatically keep the role mappings in sync. Works best with custom roles created by other plugins.", 'memberful'); ?> </p> <form method="post" action="<?php echo memberful_wp_plugin_advanced_settings_url(TRUE); ?> "> <table class="widefat fixed" id="memberful-role-mapping-table"> <thead> <tr> <th scope="col" class="manage-column"><?php _e("Map members with", 'memberful'); ?> </th> <th scope="col" class="manage-column"><?php _e("To this role", 'memberful'); ?> </th> </tr> </thead> <tbody class="role-mapping"> <?php foreach ($available_state_mappings as $state_id => $state) {