function rcp_show_user_columns($value, $column_name, $user_id)
{
    if ('rcp_status' == $column_name) {
        return rcp_get_status($user_id);
    }
    if ('rcp_subscription' == $column_name) {
        return rcp_get_subscription($user_id);
    }
    if ('rcp_links' == $column_name) {
        $page = admin_url('/admin.php?page=rcp-members');
        if (rcp_is_active($user_id)) {
            $links = '<a href="' . esc_url($page) . '&edit_member=' . esc_attr(absint($user_id)) . '">' . __('Edit Subscription', 'rcp') . '</a>';
        } else {
            $links = '<a href="' . esc_url($page) . '&edit_member=' . esc_attr(absint($user_id)) . '">' . __('Add Subscription', 'rcp') . '</a>';
        }
        return $links;
    }
    return $value;
}
Ejemplo n.º 2
0
 /**
  * Creates the pending referral during signup
  *
  * @access  public
  * @since   1.0
  */
 public function add_pending_referral($post_data, $user_id, $price)
 {
     $affiliate_discount = false;
     if (!empty($_POST['rcp_discount'])) {
         global $wpdb;
         $rcp_discounts = new RCP_Discounts();
         $discount_obj = $rcp_discounts->get_by('code', $_POST['rcp_discount']);
         $affiliate_id = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s", 'affwp_discount_rcp_' . $discount_obj->id));
         $user_id = affwp_get_affiliate_user_id($affiliate_id);
         $discount_aff = get_user_meta($user_id, 'affwp_discount_rcp_' . $discount_obj->id, true);
         if ($discount_aff && affiliate_wp()->tracking->is_valid_affiliate($affiliate_id)) {
             $affiliate_discount = true;
             $this->affiliate_id = $affiliate_id;
             $key = rcp_get_subscription_key($user_id);
             $amount = $this->calculate_referral_amount($price, $key, absint($_POST['rcp_level']));
             if (0 == $amount && affiliate_wp()->settings->get('ignore_zero_referrals')) {
                 return false;
                 // Ignore a zero amount referral
             }
             $referral_id = affiliate_wp()->referrals->add(array('amount' => $amount, 'reference' => rcp_get_subscription_key($user_id), 'description' => rcp_get_subscription($user_id), 'affiliate_id' => $this->affiliate_id, 'context' => $this->context, 'campaign' => affiliate_wp()->tracking->get_campaign()));
         }
     }
     if ($this->was_referred() && !$affiliate_discount) {
         $user = get_userdata($user_id);
         if ($this->is_affiliate_email($user->user_email)) {
             return;
             // Customers cannot refer themselves
         }
         $key = rcp_get_subscription_key($user_id);
         $total = $this->calculate_referral_amount($price, $key, absint($_POST['rcp_level']));
         $this->insert_pending_referral($total, $key, rcp_get_subscription($user_id));
     }
 }
 /**
  * Get the data being exported
  *
  * @access      public
  * @since       1.5
  * @return      array
  */
 public function get_data()
 {
     global $wpdb;
     $data = array();
     $subscription = isset($_POST['rcp-subscription']) ? absint($_POST['rcp-subscription']) : null;
     $status = isset($_POST['rcp-status']) ? sanitize_text_field($_POST['rcp-status']) : 'active';
     $offset = isset($_POST['rcp-offset']) ? absint($_POST['rcp-offset']) : null;
     $number = isset($_POST['rcp-number']) ? absint($_POST['rcp-number']) : null;
     $members = rcp_get_members($status, $subscription, $offset, $number);
     if ($members) {
         foreach ($members as $member) {
             $data[] = array('user_id' => $member->ID, 'user_login' => $member->user_login, 'user_email' => $member->user_email, 'first_name' => $member->first_name, 'last_name' => $member->last_name, 'subscription' => rcp_get_subscription($member->ID), 'subscription_key' => rcp_get_subscription_key($member->ID), 'expiration' => rcp_get_expiration_date($member->ID), 'discount_codes' => implode(' ', (array) get_user_meta($member->ID, 'rcp_user_discounts', true)));
         }
     }
     $data = apply_filters('rcp_export_get_data', $data);
     $data = apply_filters('rcp_export_get_data_' . $this->export_type, $data);
     return $data;
 }
Ejemplo n.º 4
0
<?php

/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="content">
 *
 * @package Primemovers
 */
global $current_user, $display_name, $user_email;
global $user_ID;
$subscription_id = rcp_get_subscription($user_ID);
get_currentuserinfo();
//if(! rcp_is_active()) {header('Location: http://secure.primemoversonline.com/login');}
?>
<!DOCTYPE html>
<html <?php 
language_attributes();
?>
>
<head>
<meta charset="<?php 
bloginfo('charset');
?>
">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php 
wp_title('|', true, 'right');
?>
</title>
<link rel="profile" href="http://gmpg.org/xfn/11">
function rcp_filter_email_tags($message, $user_id, $display_name)
{
    $user = get_userdata($user_id);
    $site_name = stripslashes_deep(html_entity_decode(get_bloginfo('name'), ENT_COMPAT, 'UTF-8'));
    $rcp_payments = new RCP_Payments();
    $message = str_replace('%blogname%', $site_name, $message);
    $message = str_replace('%username%', $user->user_login, $message);
    $message = str_replace('%useremail%', $user->user_email, $message);
    $message = str_replace('%firstname%', html_entity_decode($user->user_firstname, ENT_COMPAT, 'UTF-8'), $message);
    $message = str_replace('%lastname%', html_entity_decode($user->user_lastname, ENT_COMPAT, 'UTF-8'), $message);
    $message = str_replace('%displayname%', html_entity_decode($display_name, ENT_COMPAT, 'UTF-8'), $message);
    $message = str_replace('%expiration%', rcp_get_expiration_date($user_id), $message);
    $message = str_replace('%subscription_name%', html_entity_decode(rcp_get_subscription($user_id), ENT_COMPAT, 'UTF-8'), $message);
    $message = str_replace('%subscription_key%', rcp_get_subscription_key($user_id), $message);
    $message = str_replace('%amount%', html_entity_decode(rcp_currency_filter($rcp_payments->last_payment_of_user($user_id)), ENT_COMPAT, 'UTF-8'), $message);
    return apply_filters('rcp_email_tags', $message, $user_id);
}
function rcp_members_page()
{
    global $rcp_options, $rcp_db_name, $wpdb;
    $current_page = admin_url('/admin.php?page=rcp-members');
    ?>
	<div class="wrap" id="rcp-members-page">

		<?php 
    if (isset($_GET['edit_member']) || isset($_GET['view_member'])) {
        include 'edit-member.php';
    } else {
        ?>
			<h2><?php 
        _e(' Paid Subscribers', 'rcp');
        ?>
</h2>
			<?php 
        $subscription_id = isset($_GET['subscription']) && $_GET['subscription'] != 'all' ? urldecode($_GET['subscription']) : null;
        $status = !empty($_GET['status']) ? urldecode($_GET['status']) : 'active';
        $order = !empty($_GET['order']) ? urldecode($_GET['order']) : 'DESC';
        $recurring = isset($_GET['recurring']) ? absint($_GET['recurring']) : null;
        $search = !empty($_GET['s']) ? urldecode($_GET['s']) : '';
        $base_url = admin_url('admin.php?page=rcp-members');
        if ($search) {
            $base_url = add_query_arg('s', $search, $base_url);
        }
        // get subscriber count
        $active_count = rcp_count_members($subscription_id, 'active', $recurring, $search);
        $pending_count = rcp_count_members($subscription_id, 'pending', $recurring, $search);
        $expired_count = rcp_count_members($subscription_id, 'expired', $recurring, $search);
        $cancelled_count = rcp_count_members($subscription_id, 'cancelled', $recurring, $search);
        $free_count = rcp_count_members($subscription_id, 'free', $recurring, $search);
        $current_count = rcp_count_members($subscription_id, $status, $recurring, $search);
        // pagination variables
        $page = isset($_GET['p']) ? absint($_GET['p']) : 1;
        $user = get_current_user_id();
        $screen = get_current_screen();
        $screen_option = $screen->get_option('per_page', 'option');
        $per_page = get_user_meta($user, $screen_option, true);
        if (empty($per_page) || $per_page < 1) {
            $per_page = $screen->get_option('per_page', 'default');
        }
        $total_pages = 1;
        $offset = $per_page * ($page - 1);
        $total_pages = ceil($current_count / $per_page);
        ?>
			<ul class="subsubsub">
				<li><?php 
        _e('Status: ', 'rcp');
        ?>
</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'active', $base_url));
        ?>
" title="<?php 
        _e('View all active subscribers', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'active' || !isset($_GET['status']) ? 'class="current"' : '';
        ?>
>
					<?php 
        _e('Active', 'rcp');
        ?>
					</a>(<?php 
        echo $active_count;
        ?>
)
				</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'pending', $base_url));
        ?>
" title="<?php 
        _e('View all pending subscribers', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'pending' ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('Pending', 'rcp');
        ?>
					</a>(<?php 
        echo $pending_count;
        ?>
)
				</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'expired', $base_url));
        ?>
" title="<?php 
        _e('View all expired subscribers', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'expired' ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('Expired', 'rcp');
        ?>
					</a>(<?php 
        echo $expired_count;
        ?>
)
				</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'cancelled', $base_url));
        ?>
" title="<?php 
        _e('View all cancelled subscribers', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'cancelled' ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('Cancelled', 'rcp');
        ?>
					</a>(<?php 
        echo $cancelled_count;
        ?>
)
				</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'free', $base_url));
        ?>
" title="<?php 
        _e('View all free members', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'free' ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('Free', 'rcp');
        ?>
					</a>(<?php 
        echo $free_count;
        ?>
)
				</li>
				<?php 
        do_action('rcp_members_page_statuses');
        ?>
			</ul>
			<form id="rcp-member-search" method="get" action="<?php 
        menu_page_url('rcp-members');
        ?>
">
				<label class="screen-reader-text" for="rcp-member-search-input"><?php 
        _e('Search Members', 'rcp');
        ?>
</label>
				<input type="search" id="rcp-member-search-input" name="s" value="<?php 
        echo esc_attr($search);
        ?>
"/>
				<input type="hidden" name="page" value="rcp-members"/>
				<input type="hidden" name="status" value="<?php 
        echo esc_attr($status);
        ?>
"/>
				<input type="submit" name="" id="rcp-member-search-submit" class="button" value="<?php 
        _e('Search members', 'rcp');
        ?>
"/>
			</form>
			<form id="members-filter" action="" method="get">
				<?php 
        $levels = rcp_get_subscription_levels('all');
        if ($levels) {
            ?>
					<select name="subscription" id="rcp-subscription">
						<option value="all"><?php 
            _e('All Subscriptions', 'rcp');
            ?>
</option>
						<?php 
            foreach ($levels as $level) {
                echo '<option value="' . $level->id . '" ' . selected($subscription_id, $level->id, false) . '>' . $level->name . '</option>';
            }
            ?>
					</select>
				<?php 
        }
        ?>
				<select name="recurring" id="rcp-recurring">
					<option value="0"><?php 
        _e('Either', 'rcp');
        ?>
</option>
					<option value="1"<?php 
        selected(1, $recurring);
        ?>
><?php 
        _e('Not Recurring', 'rcp');
        ?>
</option>
					<option value="2"<?php 
        selected(2, $recurring);
        ?>
><?php 
        _e('Recurring', 'rcp');
        ?>
</option>
				</select>
				<select name="order" id="rcp-order">
					<option value="DESC" <?php 
        selected($order, 'DESC');
        ?>
><?php 
        _e('Newest First', 'rcp');
        ?>
</option>
					<option value="ASC" <?php 
        selected($order, 'ASC');
        ?>
><?php 
        _e('Oldest First', 'rcp');
        ?>
</option>
				</select>
				<input type="hidden" name="page" value="rcp-members"/>
				<input type="hidden" name="status" value="<?php 
        echo isset($_GET['status']) ? $_GET['status'] : 'active';
        ?>
"/>
				<input type="submit" class="button-secondary" value="<?php 
        _e('Filter', 'rcp');
        ?>
"/>
			</form>
			<?php 
        do_action('rcp_members_above_table');
        ?>
			<form id="rcp-members-form" action="<?php 
        echo esc_attr(admin_url('admin.php?page=rcp-members'));
        ?>
" method="post">
				<div id="rcp-bulk-action-options">
					<label for="rcp-bulk-member-action" class="screen-reader-text"><?php 
        _e('Select bulk action', 'rcp');
        ?>
</label>
					<select name="rcp-bulk-action" id="rcp-bulk-member-action">
						<option value="-1"><?php 
        _e('Bulk Actions', 'rcp');
        ?>
</option>
						<option value="mark-active"><?php 
        _e('Mark as Active', 'rcp');
        ?>
</option>
						<option value="mark-expired"><?php 
        _e('Mark as Expired', 'rcp');
        ?>
</option>
						<option value="mark-cancelled"><?php 
        _e('Revoke Access', 'rcp');
        ?>
</option>
						<option value="delete"><?php 
        _e('Delete', 'rcp');
        ?>
</option>
					</select>
					<input type="text" class="rcp-datepicker" name="expiration" placeholder="<?php 
        esc_attr_e('New Expiration Date', 'rcp');
        ?>
" id="rcp-bulk-expiration" value=""/>
					<input type="submit" id="rcp-submit-bulk-action" class="button action" value="<?php 
        _e('Apply', 'rcp');
        ?>
"/>
				</div>
				<?php 
        echo wp_nonce_field('rcp_bulk_edit_nonce', 'rcp_bulk_edit_nonce');
        ?>
				<table class="wp-list-table widefat fixed posts">
					<thead>
						<tr>
							<th class="rcp-checkbox-col"><input type="checkbox" id="rcp-bulk-select-all"/></th>
							<th class="rcp-user-col"><?php 
        _e('User', 'rcp');
        ?>
</th>
							<th class="rcp-id-col"><?php 
        _e('ID', 'rcp');
        ?>
</th>
							<th class="rcp-email-col"><?php 
        _e('Email', 'rcp');
        ?>
</th>
							<th class="rcp-sub-col"><?php 
        _e('Subscription', 'rcp');
        ?>
</th>
							<th class="rcp-status-col"><?php 
        _e('Status', 'rcp');
        ?>
</th>
							<th class="rcp-recurring-col"><?php 
        _e('Recurring', 'rcp');
        ?>
</th>
							<th class="rcp-expiration-col"><?php 
        _e('Expiration', 'rcp');
        ?>
</th>
							<th class="rcp-role-col"><?php 
        _e('User Role', 'rcp');
        ?>
</th>
							<?php 
        do_action('rcp_members_page_table_header');
        ?>
							<th class="rcp-actions-role"><?php 
        _e('Actions', 'rcp');
        ?>
</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<th class="rcp-checkbox-col"></th>
							<th><?php 
        _e('User', 'rcp');
        ?>
</th>
							<th><?php 
        _e('ID', 'rcp');
        ?>
</th>
							<th><?php 
        _e('Email', 'rcp');
        ?>
</th>
							<th><?php 
        _e('Subscription', 'rcp');
        ?>
</th>
							<th><?php 
        _e('Status', 'rcp');
        ?>
</th>
							<th><?php 
        _e('Recurring', 'rcp');
        ?>
</th>
							<th><?php 
        _e('Expiration', 'rcp');
        ?>
</th>
							<th><?php 
        _e('User Role', 'rcp');
        ?>
</th>
							<?php 
        do_action('rcp_members_page_table_footer');
        ?>
							<th><?php 
        _e('Actions', 'rcp');
        ?>
</th>
						</tr>
					</tfoot>
					<tbody>
					<?php 
        if (isset($_GET['signup_method'])) {
            $method = $_GET['signup_method'] == 'live' ? 'live' : 'manual';
            $members = get_users(array('meta_key' => 'rcp_signup_method', 'meta_value' => $method, 'number' => 999999));
            $per_page = 999999;
        } else {
            $members = rcp_get_members($status, $subscription_id, $offset, $per_page, $order, $recurring, $search);
        }
        if ($members) {
            $i = 1;
            foreach ($members as $key => $member) {
                ?>
							<tr class="rcp_row <?php 
                do_action('rcp_member_row_class', $member);
                if (rcp_is_odd($i)) {
                    echo ' alternate';
                }
                ?>
">
								<td>
									<input type="checkbox" class="rcp-member-cb" name="member-ids[]" value="<?php 
                echo absint($member->ID);
                ?>
"/>
								</td>
								<td><a href="<?php 
                echo add_query_arg('user_id', $member->ID, admin_url('user-edit.php'));
                ?>
" title="<?php 
                _e('View User\'s Profile', 'rcp');
                ?>
"><?php 
                echo $member->user_login;
                ?>
</a></td>
								<td><?php 
                echo $member->ID;
                ?>
</td>
								<td><?php 
                echo $member->user_email;
                ?>
</td>
								<td><?php 
                echo rcp_get_subscription($member->ID);
                ?>
</td>
								<td><?php 
                echo rcp_print_status($member->ID, false);
                ?>
</td>
								<td><?php 
                echo rcp_is_recurring($member->ID) ? __('yes', 'rcp') : __('no', 'rcp');
                ?>
								<td><?php 
                echo rcp_get_expiration_date($member->ID);
                ?>
</td>
								<td><?php 
                echo rcp_get_user_role($member->ID);
                ?>
</td>
								<?php 
                do_action('rcp_members_page_table_column', $member->ID);
                ?>
								<td>								
									<?php 
                if (current_user_can('rcp_manage_members')) {
                    ?>
										<a href="<?php 
                    echo esc_url(add_query_arg('edit_member', $member->ID, $current_page));
                    ?>
"><?php 
                    _e('Edit', 'rcp');
                    ?>
</a>
										<?php 
                    if (isset($_GET['status']) && $_GET['status'] == 'cancelled') {
                        ?>
											| <a href="<?php 
                        echo esc_url(add_query_arg('activate_member', $member->ID, $current_page));
                        ?>
" class="rcp_activate"><?php 
                        _e('Enable Access', 'rcp');
                        ?>
</a>
										<?php 
                    } elseif (isset($_GET['status']) && $_GET['status'] == 'active' || !isset($_GET['status'])) {
                        ?>
											| <a href="<?php 
                        echo esc_url(add_query_arg('revoke_access', $member->ID, $current_page));
                        ?>
" class="rcp_revoke"><?php 
                        _e('Revoke Access', 'rcp');
                        ?>
</a>
										<?php 
                    }
                    ?>
										<?php 
                    if (rcp_can_member_cancel($member->ID)) {
                        ?>
											| <a href="<?php 
                        echo wp_nonce_url(add_query_arg('cancel_member', $member->ID, $current_page), 'rcp-cancel-nonce');
                        ?>
" class="rcp_cancel"><?php 
                        _e('Cancel', 'rcp');
                        ?>
</a>
										<?php 
                    }
                    ?>
										<?php 
                    if ($switch_to_url = rcp_get_switch_to_url($member->ID)) {
                        ?>
											| <a href="<?php 
                        echo esc_url($switch_to_url);
                        ?>
" class="rcp_switch"><?php 
                        _e('Switch to User', 'rcp');
                        ?>
</a>
										<?php 
                    }
                    ?>
										<?php 
                    do_action('rcp_member_row_actions', $member->ID);
                    ?>
									<?php 
                }
                ?>
								</td>
							</tr>
						<?php 
                $i++;
            }
        } else {
            ?>
						<tr><td colspan="9"><?php 
            _e('No subscribers found', 'rcp');
            ?>
</td></tr>
					<?php 
        }
        ?>
				</table>
			</form>
			<?php 
        if ($total_pages > 1 && !isset($_GET['signup_method'])) {
            ?>
				<div class="tablenav">
					<div class="tablenav-pages alignright">
						<?php 
            $query_string = $_SERVER['QUERY_STRING'];
            $base = 'admin.php?' . remove_query_arg('p', $query_string) . '%_%';
            echo paginate_links(array('base' => $base, 'format' => '&p=%#%', 'prev_text' => __('&laquo; Previous'), 'next_text' => __('Next &raquo;'), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5));
            ?>
				    </div>
				</div><!--end .tablenav-->
			<?php 
        }
        ?>
			<?php 
        do_action('rcp_members_below_table');
        ?>
			<h3><?php 
        _e('Add New Subscription (for existing user)', 'rcp');
        ?>
</h3>
			<form id="rcp-add-new-member" action="" method="post">
				<table class="form-table">
					<tbody>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="rcp-username"><?php 
        _e('Username', 'rcp');
        ?>
</label>
							</th>
							<td>
								<input type="text" name="user" id="rcp-user" autocomplete="off" class="regular-text rcp-user-search" style="width: 120px;"/>
								<img class="rcp-ajax waiting" src="<?php 
        echo admin_url('images/wpspin_light.gif');
        ?>
" style="display: none;"/>
								<div id="rcp_user_search_results"></div>
								<p class="description"><?php 
        _e('Begin typing the user name to add a subscription to.', 'rcp');
        ?>
</p>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="rcp-level"><?php 
        _e('Subscription Level', 'rcp');
        ?>
</label>
							</th>
							<td>
								<select name="level" id="rcp-level">
									<option value="choose"><?php 
        _e('--choose--', 'rcp');
        ?>
</option>
									<?php 
        foreach (rcp_get_subscription_levels() as $level) {
            echo '<option value="' . $level->id . '">' . $level->name . '</option>';
        }
        ?>
								</select>
								<p class="description"><?php 
        _e('Choose the subscription level for this user', 'rcp');
        ?>
</p>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="rcp-expiration"><?php 
        _e('Expiration date', 'rcp');
        ?>
</label>
							</th>
							<td>
								<input name="expiration" id="rcp-expiration" type="text" style="width: 120px;" class="rcp-datepicker"/>
								<label for="rcp-unlimited">
									<input name="unlimited" id="rcp-unlimited" type="checkbox"/>
									<span class="description"><?php 
        _e('Never expires?', 'rcp');
        ?>
</span>
								</label>
								<p class="description"><?php 
        _e('Enter the expiration date for this user in the format of yyyy-mm-dd', 'rcp');
        ?>
</p>
							</td>
						</tr>
					</tbody>
				</table>
				<p class="submit">
					<input type="hidden" name="rcp-action" value="add-subscription"/>
					<input type="submit" value="<?php 
        _e('Add User Subscription', 'rcp');
        ?>
" class="button-primary"/>
				</p>
			</form>

		<?php 
    }
    ?>

	</div><!--end wrap-->

	<?php 
}
Ejemplo n.º 7
0
function rcp_process_data()
{
    if (!is_admin()) {
        return;
    }
    if (!empty($_POST)) {
        /****************************************
         * subscription levels
         ****************************************/
        // add a new subscription level
        if (isset($_POST['rcp-action']) && $_POST['rcp-action'] == 'add-level') {
            if (!current_user_can('rcp_manage_levels')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $levels = new RCP_Levels();
            $add = $levels->insert($_POST);
            if ($add) {
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-member-levels&rcp_message=level_added';
            } else {
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-member-levels&rcp_message=level_not_added';
            }
            wp_safe_redirect($url);
            exit;
        }
        // edit a subscription level
        if (isset($_POST['rcp-action']) && $_POST['rcp-action'] == 'edit-subscription') {
            if (!current_user_can('rcp_manage_levels')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $levels = new RCP_Levels();
            $update = $levels->update($_POST['subscription_id'], $_POST);
            if ($update) {
                // clear the cache
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-member-levels&rcp_message=level_updated';
            } else {
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-member-levels&rcp_message=level_not_updated';
            }
            wp_safe_redirect($url);
            exit;
        }
        // add a subscription for an existing member
        if (isset($_POST['rcp-action']) && $_POST['rcp-action'] == 'add-subscription') {
            if (!current_user_can('rcp_manage_members')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            if (isset($_POST['expiration']) && strtotime('NOW') > strtotime($_POST['expiration']) && 'none' !== $_POST['expiration']) {
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-members&rcp_message=user_not_added';
                header("Location:" . $url);
            } else {
                $levels = new RCP_Levels();
                $user = get_user_by('login', $_POST['user']);
                $expiration = isset($_POST['expiration']) ? sanitize_text_field($_POST['expiration']) : 'none';
                $level_id = absint($_POST['level']);
                rcp_set_expiration_date($user->ID, $expiration);
                rcp_set_status($user->ID, 'active');
                update_user_meta($user->ID, 'rcp_signup_method', 'manual');
                // Add a role, if needed, to the user
                $subscription = $levels->get_level($level_id);
                update_user_meta($user->ID, 'rcp_subscription_level', $level_id);
                // Add the new user role
                $role = !empty($subscription->role) ? $subscription->role : 'subscriber';
                $user->add_role($role);
                if (isset($_POST['recurring'])) {
                    update_user_meta($user->ID, 'rcp_recurring', 'yes');
                } else {
                    delete_user_meta($user->ID, 'rcp_recurring');
                }
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-members&rcp_message=user_added';
                header("Location:" . $url);
            }
        }
        // bulk edit members
        if (isset($_POST['rcp-bulk-action']) && $_POST['rcp-bulk-action']) {
            if (!wp_verify_nonce($_POST['rcp_bulk_edit_nonce'], 'rcp_bulk_edit_nonce')) {
                wp_die(__('Nonce verification failed.', 'rcp'));
            }
            if (!current_user_can('rcp_manage_members')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            if (empty($_POST['member-ids'])) {
                wp_die(__('Please select at least one member to edit.', 'rcp'));
            }
            $member_ids = array_map('absint', $_POST['member-ids']);
            $action = !empty($_POST['rcp-bulk-action']) ? sanitize_text_field($_POST['rcp-bulk-action']) : false;
            foreach ($member_ids as $member_id) {
                $member = new RCP_Member($member_id);
                if (!empty($_POST['expiration']) && 'delete' !== $action) {
                    $member->set_expiration_date(date('Y-m-d H:i:s', strtotime($_POST['expiration'])));
                }
                if ($action) {
                    switch ($action) {
                        case 'mark-active':
                            $member->set_status('active');
                            break;
                        case 'mark-expired':
                            $member->set_status('expired');
                            break;
                        case 'mark-cancelled':
                            $member->set_status('cancelled');
                            break;
                        case 'delete':
                            wp_delete_user($member->ID);
                            break;
                    }
                }
            }
            wp_redirect(admin_url('admin.php?page=rcp-members&rcp_message=members_updated'));
            exit;
        }
        // edit a member's subscription
        if (isset($_POST['rcp-action']) && $_POST['rcp-action'] == 'edit-member') {
            if (!current_user_can('rcp_manage_members')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $levels = new RCP_Levels();
            $user_id = absint($_POST['user']);
            $member = new RCP_Member($user_id);
            $status = sanitize_text_field($_POST['status']);
            $level_id = absint($_POST['level']);
            $expiration = isset($_POST['expiration']) ? sanitize_text_field($_POST['expiration']) : 'none';
            $expiration = 'none' !== $expiration ? date('Y-m-d 23:59:59', strtotime($_POST['expiration'])) : $expiration;
            if (!empty($_POST['expiration'])) {
                $member->set_expiration_date($expiration);
            }
            if (isset($_POST['level'])) {
                $current_id = rcp_get_subscription_id($user_id);
                $new_level = $levels->get_level($level_id);
                $old_level = $levels->get_level($current_id);
                if ($current_id != $level_id) {
                    update_user_meta($user_id, 'rcp_subscription_level', $level_id);
                    // Remove the old user role
                    $role = !empty($old_level->role) ? $old_level->role : 'subscriber';
                    $member->remove_role($role);
                    // Add the new user role
                    $role = !empty($new_level->role) ? $new_level->role : 'subscriber';
                    $member->add_role($role);
                }
            }
            if (isset($_POST['recurring'])) {
                $member->set_recurring(true);
            } else {
                $member->set_recurring(false);
            }
            if (isset($_POST['trialing'])) {
                update_user_meta($user_id, 'rcp_is_trialing', 'yes');
            } else {
                delete_user_meta($user_id, 'rcp_is_trialing');
            }
            if (isset($_POST['signup_method'])) {
                update_user_meta($user_id, 'rcp_signup_method', $_POST['signup_method']);
            }
            if (isset($_POST['notes'])) {
                update_user_meta($user_id, 'rcp_notes', wp_kses($_POST['notes'], array()));
            }
            if (isset($_POST['status'])) {
                rcp_set_status($user_id, $status);
            }
            if (isset($_POST['payment-profile-id'])) {
                $member->set_payment_profile_id($_POST['payment-profile-id']);
            }
            do_action('rcp_edit_member', $user_id);
            wp_redirect(admin_url('admin.php?page=rcp-members&edit_member=' . $user_id . '&rcp_message=user_updated'));
            exit;
        }
        /****************************************
         * discount codes
         ****************************************/
        // add a new discount code
        if (isset($_POST['rcp-action']) && $_POST['rcp-action'] == 'add-discount') {
            if (!current_user_can('rcp_manage_discounts')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $discounts = new RCP_Discounts();
            // Setup unsanitized data
            $data = array('name' => $_POST['name'], 'description' => $_POST['description'], 'amount' => $_POST['amount'], 'unit' => isset($_POST['unit']) && $_POST['unit'] == '%' ? '%' : 'flat', 'code' => $_POST['code'], 'status' => 'active', 'expiration' => $_POST['expiration'], 'max_uses' => $_POST['max'], 'subscription_id' => $_POST['subscription']);
            $add = $discounts->insert($data);
            if ($add) {
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-discounts&rcp_message=discount_added';
            } else {
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-discounts&rcp_message=discount_not_added';
            }
            wp_safe_redirect($url);
            exit;
        }
        // edit a discount code
        if (isset($_POST['rcp-action']) && $_POST['rcp-action'] == 'edit-discount') {
            if (!current_user_can('rcp_manage_discounts')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $discounts = new RCP_Discounts();
            // Setup unsanitized data
            $data = array('name' => $_POST['name'], 'description' => $_POST['description'], 'amount' => $_POST['amount'], 'unit' => isset($_POST['unit']) && $_POST['unit'] == '%' ? '%' : 'flat', 'code' => $_POST['code'], 'status' => $_POST['status'], 'expiration' => $_POST['expiration'], 'max_uses' => $_POST['max'], 'subscription_id' => $_POST['subscription']);
            $update = $discounts->update($_POST['discount_id'], $data);
            if ($update) {
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-discounts&discount-updated=1';
            } else {
                $url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=rcp-discounts&discount-updated=0';
            }
            wp_safe_redirect($url);
            exit;
        }
        // add a new manual payment
        if (isset($_POST['rcp-action']) && $_POST['rcp-action'] == 'add-payment') {
            if (!current_user_can('rcp_manage_payments')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $payments = new RCP_Payments();
            $user = get_user_by('login', $_POST['user']);
            if ($user) {
                $data = array('amount' => empty($_POST['amount']) ? 0.0 : sanitize_text_field($_POST['amount']), 'user_id' => $user->ID, 'date' => empty($_POST['date']) ? date('Y-m-d H:i:s', current_time('timestamp')) : date('Y-m-d', strtotime($_POST['date'], current_time('timestamp'))) . ' ' . date('H:i:s', current_time('timestamp')), 'payment_type' => 'manual', 'subscription' => rcp_get_subscription($user->ID), 'subscription_key' => rcp_get_subscription_key($user->ID), 'transaction_id' => sanitize_text_field($_POST['transaction-id']), 'status' => sanitize_text_field($_POST['status']));
                $add = $payments->insert($data);
            }
            if (!empty($add)) {
                $cache_args = array('earnings' => 1, 'subscription' => 0, 'user_id' => 0, 'date' => '');
                $cache_key = md5(implode(',', $cache_args));
                delete_transient($cache_key);
                $url = admin_url('admin.php?page=rcp-payments&rcp_message=payment_added');
            } else {
                $url = admin_url('admin.php?page=rcp-payments&rcp_message=payment_not_added');
            }
            wp_safe_redirect($url);
            exit;
        }
        // edit a payment
        if (isset($_POST['rcp-action']) && $_POST['rcp-action'] == 'edit-payment') {
            if (!current_user_can('rcp_manage_payments')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $payments = new RCP_Payments();
            $payment_id = absint($_POST['payment-id']);
            $user = get_user_by('login', $_POST['user']);
            if ($user && $payment_id) {
                $data = array('amount' => empty($_POST['amount']) ? 0.0 : sanitize_text_field($_POST['amount']), 'user_id' => $user->ID, 'date' => empty($_POST['date']) ? date('Y-m-d H:i:s', current_time('timestamp')) : date('Y-m-d', strtotime($_POST['date'], current_time('timestamp'))) . ' ' . date('H:i:s', current_time('timestamp')), 'subscription' => rcp_get_subscription($user->ID), 'subscription_key' => rcp_get_subscription_key($user->ID), 'transaction_id' => sanitize_text_field($_POST['transaction-id']), 'status' => sanitize_text_field($_POST['status']));
                $update = $payments->update($payment_id, $data);
            }
            if (!empty($update)) {
                $cache_args = array('earnings' => 1, 'subscription' => 0, 'user_id' => 0, 'date' => '');
                $cache_key = md5(implode(',', $cache_args));
                delete_transient($cache_key);
                $url = admin_url('admin.php?page=rcp-payments&rcp_message=payment_updated');
            } else {
                $url = admin_url('admin.php?page=rcp-payments&rcp_message=payment_not_updated');
            }
            wp_safe_redirect($url);
            exit;
        }
    }
    /*************************************
     * delete data
     *************************************/
    if (!empty($_GET)) {
        /* member processing */
        if (isset($_GET['revoke_access'])) {
            if (!current_user_can('rcp_manage_members')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            rcp_set_status(urldecode(absint($_GET['revoke_access'])), 'cancelled');
        }
        if (isset($_GET['activate_member'])) {
            if (!current_user_can('rcp_manage_members')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            rcp_set_status(urldecode(absint($_GET['activate_member'])), 'active');
        }
        if (isset($_GET['cancel_member'])) {
            if (!current_user_can('rcp_manage_members')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            rcp_cancel_member_payment_profile(urldecode(absint($_GET['cancel_member'])));
            wp_safe_redirect(admin_url(add_query_arg('rcp_message', 'member_cancelled', 'admin.php?page=rcp-members')));
            exit;
        }
        /* subscription processing */
        if (isset($_GET['delete_subscription']) && $_GET['delete_subscription'] > 0) {
            if (!current_user_can('rcp_manage_levels')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $members_of_subscription = rcp_get_members_of_subscription(absint($_GET['delete_subscription']));
            // cancel all active members of this subscription
            if ($members_of_subscription) {
                foreach ($members_of_subscription as $member) {
                    rcp_set_status($member, 'cancelled');
                }
            }
            $levels = new RCP_Levels();
            $levels->remove($_GET['delete_subscription']);
        }
        if (isset($_GET['activate_subscription']) && $_GET['activate_subscription'] > 0) {
            if (!current_user_can('rcp_manage_levels')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $levels = new RCP_Levels();
            $update = $levels->update(absint($_GET['activate_subscription']), array('status' => 'active'));
            delete_transient('rcp_subscription_levels');
        }
        if (isset($_GET['deactivate_subscription']) && $_GET['deactivate_subscription'] > 0) {
            if (!current_user_can('rcp_manage_levels')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $levels = new RCP_Levels();
            $update = $levels->update(absint($_GET['deactivate_subscription']), array('status' => 'inactive'));
            delete_transient('rcp_subscription_levels');
        }
        /* discount processing */
        if (!empty($_GET['delete_discount'])) {
            if (!current_user_can('rcp_manage_discounts')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $discounts = new RCP_Discounts();
            $discounts->delete($_GET['delete_discount']);
        }
        if (!empty($_GET['activate_discount'])) {
            if (!current_user_can('rcp_manage_discounts')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $discounts = new RCP_Discounts();
            $discounts->update($_GET['activate_discount'], array('status' => 'active'));
        }
        if (!empty($_GET['deactivate_discount'])) {
            if (!current_user_can('rcp_manage_discounts')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $discounts = new RCP_Discounts();
            $discounts->update($_GET['deactivate_discount'], array('status' => 'disabled'));
        }
        if (!empty($_GET['rcp-action']) && $_GET['rcp-action'] == 'delete_payment' && wp_verify_nonce($_GET['_wpnonce'], 'rcp_delete_payment_nonce')) {
            if (!current_user_can('rcp_manage_payments')) {
                wp_die(__('You do not have permission to perform this action.', 'rcp'));
            }
            $payments = new RCP_Payments();
            $payments->delete(absint($_GET['payment_id']));
            wp_safe_redirect(admin_url(add_query_arg('rcp_message', 'payment_deleted', 'admin.php?page=rcp-payments')));
            exit;
        }
    }
}
Ejemplo n.º 8
0
			</th>
			<td>
				<?php 
echo rcp_get_status($user->ID);
?>
			</td>
		</tr>
		<tr class="form-field">
			<th scope="row" valign="top">
				<?php 
_e('Subscription Level', 'rcp');
?>
			</th>
			<td>
				<?php 
echo rcp_get_subscription($user->ID);
?>
			</td>
		</tr>
		<tr class="form-field">
			<th scope="row" valign="top">
				<?php 
_e('Expiration date', 'rcp');
?>
			</th>
			<td>
				<?php 
echo rcp_get_expiration_date($user->ID);
?>
			</td>
		</tr>
Ejemplo n.º 9
0
}
?>
			<th><?php 
_e('Actions', 'rcp');
?>
</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><?php 
rcp_print_status();
?>
</td>
			<td><?php 
echo rcp_get_subscription();
?>
</td>
			<td><?php 
echo rcp_get_expiration_date();
?>
</td>
			<td>
				<?php 
if ((rcp_is_expired($user_ID) || !rcp_is_recurring($user_ID) || rcp_get_status($user_ID) == 'cancelled') && rcp_subscription_upgrade_possible($user_ID)) {
    echo '<a href="' . esc_url(get_permalink($rcp_options['registration_page'])) . '" title="' . __('Renew your subscription', 'rcp') . '" class="rcp_sub_details_renew">' . __('Renew your subscription', 'rcp') . '</a>';
} elseif (!rcp_is_active($user_ID) && rcp_subscription_upgrade_possible($user_ID)) {
    echo '<a href="' . esc_url(get_permalink($rcp_options['registration_page'])) . '" title="' . __('Upgrade your subscription', 'rcp') . '" class="rcp_sub_details_renew">' . __('Upgrade your subscription', 'rcp') . '</a>';
} elseif (rcp_is_active($user_ID) && rcp_is_paypal_subscriber()) {
    echo '<a href="https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_manage-paylist" target="_blank" title="' . __('Cancel your subscription', 'rcp') . '">' . __('Cancel your subscription', 'rcp') . '</a>';
}
Ejemplo n.º 10
0
	<thead>
		<tr>
			<th><?php _e( 'Status', 'rcp' ); ?></th>
			<th><?php _e( 'Subscription', 'rcp' ); ?></th>
			<?php if( rcp_is_recurring() && ! rcp_is_expired() ) : ?>
			<th><?php _e( 'Renewal Date', 'rcp' ); ?></th>
			<?php else : ?>
			<th><?php _e( 'Expiration', 'rcp' ); ?></th>
			<?php endif; ?>
			<th><?php _e( 'Actions', 'rcp' ); ?></th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><?php rcp_print_status(); ?></td>
			<td><?php echo rcp_get_subscription(); ?></td>
			<td><?php echo rcp_get_expiration_date(); ?></td>
			<td>
				<?php
				if( ( ( rcp_is_expired( $user_ID ) || ! rcp_is_recurring( $user_ID ) ) || rcp_get_status( $user_ID ) == 'cancelled' ) && rcp_subscription_upgrade_possible( $user_ID ) ) {
					echo '<a href="' . esc_url( get_permalink( $rcp_options['registration_page'] ) ) . '" title="' . __( 'Renew your subscription', 'rcp' ) . '" class="rcp_sub_details_renew">' . __( 'Renew your subscription', 'rcp' ) . '</a>';
				} elseif( ! rcp_is_active( $user_ID ) && rcp_subscription_upgrade_possible( $user_ID ) ) {
					echo '<a href="' . esc_url( get_permalink( $rcp_options['registration_page'] ) ) . '" title="' . __( 'Upgrade your subscription', 'rcp' ) . '" class="rcp_sub_details_renew">' . __( 'Upgrade your subscription', 'rcp' ) . '</a>';
				} elseif( rcp_is_active( $user_ID ) && rcp_can_member_cancel( $user_ID ) ) {
					echo '<a href="' . rcp_get_member_cancel_url( $user_ID ) . '" title="' . __( 'Cancel your subscription', 'rcp' ) . '">' . __( 'Cancel your subscription', 'rcp' ) . '</a>';
				}
				do_action( 'rcp_subscription_details_action_links' );
				?>
			</td>
		</tr>
	</tbody>
Ejemplo n.º 11
0
?>
</p>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row" valign="top">
					<label for="rcp-level"><?php 
_e('Subscription Level', 'rcp');
?>
</label>
				</th>
				<td>
					<select name="level" id="rcp-level">
						<?php 
foreach (rcp_get_subscription_levels('all') as $key => $level) {
    echo '<option value="' . esc_attr(absint($level->id)) . '"' . selected($level->name, rcp_get_subscription($member->ID), false) . '>' . esc_html($level->name) . '</option>';
}
?>
					</select>
					<p class="description"><?php 
_e('Choose the subscription level for this user', 'rcp');
?>
</p>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row" valign="top">
					<label for="rcp-key"><?php 
_e('Subscription Key', 'rcp');
?>
</label>
function rcp_members_page()
{
    global $rcp_options, $rcp_db_name, $wpdb;
    $current_page = admin_url('/admin.php?page=rcp-members');
    ?>
	<div class="wrap" id="rcp-members-page">

		<?php 
    if (isset($_GET['edit_member']) || isset($_GET['view_member'])) {
        include 'edit-member.php';
    } else {
        ?>
			<h2><?php 
        _e(' Paid Subscribers', 'rcp');
        ?>
</h2>
			<?php 
        $subscription_id = isset($_GET['subscription']) && $_GET['subscription'] != 'all' ? urldecode($_GET['subscription']) : null;
        $status = !empty($_GET['status']) ? urldecode($_GET['status']) : 'active';
        $order = !empty($_GET['order']) ? urldecode($_GET['order']) : 'DESC';
        $search = !empty($_GET['s']) ? urldecode($_GET['s']) : '';
        $base_url = admin_url('admin.php?page=rcp-members');
        if ($search) {
            $base_url = add_query_arg('s', $search, $base_url);
        }
        // Get subscriber count
        if (!empty($search) || !empty($subscription_id)) {
            // Query counts
            $active_count = rcp_count_members($subscription_id, 'active', null, $search);
            $pending_count = rcp_count_members($subscription_id, 'pending', null, $search);
            $expired_count = rcp_count_members($subscription_id, 'expired', null, $search);
            $cancelled_count = rcp_count_members($subscription_id, 'cancelled', null, $search);
            $free_count = rcp_count_members($subscription_id, 'free', null, $search);
            $current_count = rcp_count_members($subscription_id, $status, null, $search);
        } else {
            // Retrieve static counts
            $active_count = rcp_get_member_count('active');
            $pending_count = rcp_get_member_count('pending');
            $expired_count = rcp_get_member_count('expired');
            $cancelled_count = rcp_get_member_count('cancelled');
            $free_count = rcp_get_member_count('free');
            $current_count = rcp_get_member_count($status);
        }
        // pagination variables
        $page = isset($_GET['p']) ? absint($_GET['p']) : 1;
        $user = get_current_user_id();
        $screen = get_current_screen();
        $screen_option = $screen->get_option('per_page', 'option');
        $per_page = get_user_meta($user, $screen_option, true);
        if (empty($per_page) || $per_page < 1) {
            $per_page = $screen->get_option('per_page', 'default');
        }
        $total_pages = 1;
        $offset = $per_page * ($page - 1);
        $total_pages = ceil($current_count / $per_page);
        ?>
			<ul class="subsubsub">
				<li><?php 
        _e('Status: ', 'rcp');
        ?>
</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'active', $base_url));
        ?>
" title="<?php 
        _e('View all active subscribers', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'active' || !isset($_GET['status']) ? 'class="current"' : '';
        ?>
>
					<?php 
        _e('Active', 'rcp');
        ?>
					</a>(<?php 
        echo $active_count;
        ?>
)
				</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'pending', $base_url));
        ?>
" title="<?php 
        _e('View all pending subscribers', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'pending' ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('Pending', 'rcp');
        ?>
					</a>(<?php 
        echo $pending_count;
        ?>
)
				</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'expired', $base_url));
        ?>
" title="<?php 
        _e('View all expired subscribers', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'expired' ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('Expired', 'rcp');
        ?>
					</a>(<?php 
        echo $expired_count;
        ?>
)
				</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'cancelled', $base_url));
        ?>
" title="<?php 
        _e('View all cancelled subscribers', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'cancelled' ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('Cancelled', 'rcp');
        ?>
					</a>(<?php 
        echo $cancelled_count;
        ?>
)
				</li>
				<li>
					<a href="<?php 
        echo esc_url(add_query_arg('status', 'free', $base_url));
        ?>
" title="<?php 
        _e('View all free members', 'rcp');
        ?>
" <?php 
        echo isset($_GET['status']) && $_GET['status'] == 'free' ? 'class="current"' : '';
        ?>
>
						<?php 
        _e('Free', 'rcp');
        ?>
					</a>(<?php 
        echo $free_count;
        ?>
)
				</li>
				<?php 
        do_action('rcp_members_page_statuses');
        ?>
			</ul>
			<form id="rcp-member-search" method="get" action="<?php 
        menu_page_url('rcp-members');
        ?>
">
				<label class="screen-reader-text" for="rcp-member-search-input"><?php 
        _e('Search Members', 'rcp');
        ?>
</label>
				<input type="search" id="rcp-member-search-input" name="s" value="<?php 
        echo esc_attr($search);
        ?>
"/>
				<input type="hidden" name="page" value="rcp-members"/>
				<input type="hidden" name="status" value="<?php 
        echo esc_attr($status);
        ?>
"/>
				<input type="submit" name="" id="rcp-member-search-submit" class="button" value="<?php 
        _e('Search members', 'rcp');
        ?>
"/>
			</form>
			<form id="members-filter" action="" method="get">
				<?php 
        $levels = rcp_get_subscription_levels('all');
        if ($levels) {
            ?>
					<select name="subscription" id="rcp-subscription">
						<option value="all"><?php 
            _e('All Subscriptions', 'rcp');
            ?>
</option>
						<?php 
            foreach ($levels as $level) {
                echo '<option value="' . $level->id . '" ' . selected($subscription_id, $level->id, false) . '>' . $level->name . '</option>';
            }
            ?>
					</select>
				<?php 
        }
        ?>
				<select name="order" id="rcp-order">
					<option value="DESC" <?php 
        selected($order, 'DESC');
        ?>
><?php 
        _e('Newest First', 'rcp');
        ?>
</option>
					<option value="ASC" <?php 
        selected($order, 'ASC');
        ?>
><?php 
        _e('Oldest First', 'rcp');
        ?>
</option>
				</select>
				<input type="hidden" name="page" value="rcp-members"/>
				<input type="hidden" name="status" value="<?php 
        echo isset($_GET['status']) ? $_GET['status'] : 'active';
        ?>
"/>
				<input type="submit" class="button-secondary" value="<?php 
        _e('Filter', 'rcp');
        ?>
"/>
			</form>
			<?php 
        do_action('rcp_members_above_table');
        ?>
			<form id="rcp-members-form" action="<?php 
        echo esc_attr(admin_url('admin.php?page=rcp-members'));
        ?>
" method="post">
				<div id="rcp-bulk-action-options" class="tablenav top">
					<label for="rcp-bulk-member-action" class="screen-reader-text"><?php 
        _e('Select bulk action', 'rcp');
        ?>
</label>
					<select name="rcp-bulk-action" id="rcp-bulk-member-action">
						<option value="-1"><?php 
        _e('Bulk Actions', 'rcp');
        ?>
</option>
						<option value="mark-active"><?php 
        _e('Mark as Active', 'rcp');
        ?>
</option>
						<option value="mark-expired"><?php 
        _e('Mark as Expired', 'rcp');
        ?>
</option>
						<option value="mark-cancelled"><?php 
        _e('Revoke Access', 'rcp');
        ?>
</option>
					</select>
					<input type="text" class="rcp-datepicker" name="expiration" placeholder="<?php 
        esc_attr_e('New Expiration Date', 'rcp');
        ?>
" id="rcp-bulk-expiration" value=""/>
					<input type="submit" id="rcp-submit-bulk-action" class="button action" value="<?php 
        _e('Apply', 'rcp');
        ?>
"/>
				</div>
				<?php 
        wp_nonce_field('rcp_bulk_edit_nonce', 'rcp_bulk_edit_nonce');
        ?>
				<table class="wp-list-table widefat">
					<thead>
						<tr>
							<td id="cb" class="manage-column column-cb check-column">
								<label class="screen-reader-text" for="cb-select-all-1"><?php 
        _e('Select All', 'rcp');
        ?>
</label>
								<input id="cb-select-all-1" type="checkbox">
							</td>
							<th scope="col" class="rcp-user-col manage-column column-primary"><?php 
        _e('User', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-sub-col manage-column"><?php 
        _e('Subscription', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-status-col manage-column"><?php 
        _e('Status', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-recurring-col manage-column"><?php 
        _e('Recurring', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-expiration-col manage-column"><?php 
        _e('Expiration', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-role-col manage-column"><?php 
        _e('User Role', 'rcp');
        ?>
</th>
							<?php 
        do_action('rcp_members_page_table_header');
        ?>
						</tr>
					</thead>
					<tbody id="the-list">
					<?php 
        if (isset($_GET['signup_method'])) {
            $method = $_GET['signup_method'] == 'live' ? 'live' : 'manual';
            $members = get_users(array('meta_key' => 'rcp_signup_method', 'meta_value' => $method, 'number' => 999999));
            $per_page = 999999;
        } else {
            $members = rcp_get_members($status, $subscription_id, $offset, $per_page, $order, null, $search);
        }
        if ($members) {
            $i = 1;
            foreach ($members as $key => $member) {
                $rcp_member = new RCP_Member($member->ID);
                // Show pending expiration date for members with a pending status. See https://github.com/restrictcontentpro/restrict-content-pro/issues/708.
                if ('pending' === $status) {
                    $expiration = $rcp_member->get_expiration_date(true, true);
                } else {
                    $expiration = $rcp_member->get_expiration_date(true, false);
                }
                ?>
							<tr class="rcp_row <?php 
                do_action('rcp_member_row_class', $member);
                if (rcp_is_odd($i)) {
                    echo ' alternate';
                }
                ?>
">
								<th scope="row" class="check-column">
									<input type="checkbox" class="rcp-member-cb" name="member-ids[]" value="<?php 
                echo absint($member->ID);
                ?>
"/>
								</th>
								<td class="has-row-actions column-primary" data-colname="<?php 
                _e('User', 'rcp');
                ?>
">
									<strong>
										<a href="<?php 
                echo esc_url(add_query_arg('edit_member', $member->ID, $current_page));
                ?>
" title="<?php 
                _e('Edit Member', 'rcp');
                ?>
"><?php 
                echo $member->user_login;
                ?>
</a>
										<?php 
                if ($member->user_login != $member->user_email) {
                    ?>
											<?php 
                    echo '&nbsp;&ndash;&nbsp;' . $member->user_email;
                    ?>
										<?php 
                }
                ?>
									</strong>
									<?php 
                if (current_user_can('rcp_manage_members')) {
                    ?>
										<div class="row-actions">
											<span class="edit">
												<a href="<?php 
                    echo esc_url(add_query_arg('edit_member', $member->ID, $current_page));
                    ?>
"><?php 
                    _e('Edit Member', 'rcp');
                    ?>
</a>
												<span class="rcp-separator"> | </span>
												<a href="<?php 
                    echo esc_url(add_query_arg('user_id', $member->ID, admin_url('user-edit.php')));
                    ?>
" title="<?php 
                    _e('View User\'s Profile', 'rcp');
                    ?>
"><?php 
                    _e('Edit User Account', 'rcp');
                    ?>
</a>
											</span>
											<?php 
                    if (rcp_can_member_cancel($member->ID)) {
                        ?>
												<span> | <a href="<?php 
                        echo wp_nonce_url(add_query_arg('cancel_member', $member->ID, $current_page), 'rcp-cancel-nonce');
                        ?>
" class="trash rcp_cancel"><?php 
                        _e('Cancel', 'rcp');
                        ?>
</a></span>
											<?php 
                    }
                    ?>
											<?php 
                    if ($switch_to_url = rcp_get_switch_to_url($member->ID)) {
                        ?>
												<span> | <a href="<?php 
                        echo esc_url($switch_to_url);
                        ?>
" class="rcp_switch"><?php 
                        _e('Switch to User', 'rcp');
                        ?>
</a></span>
											<?php 
                    }
                    ?>
											<span class="rcp-separator"> | </span>
											<span class="id rcp-member-id"><?php 
                    echo __('ID:', 'rcp') . ' ' . $member->ID;
                    ?>
</span>
											<?php 
                    do_action('rcp_member_row_actions', $member->ID);
                    ?>
										</div>
									<?php 
                }
                ?>
									<button type="button" class="toggle-row"><span class="screen-reader-text"><?php 
                _e('Show more details', 'rcp');
                ?>
</span></button>
								</td>
								<td data-colname="<?php 
                _e('Subscription', 'rcp');
                ?>
"><?php 
                echo rcp_get_subscription($member->ID);
                ?>
</td>
								<td data-colname="<?php 
                _e('Status', 'rcp');
                ?>
"><?php 
                echo rcp_print_status($member->ID, false);
                ?>
</td>
								<td data-colname="<?php 
                _e('Recurring', 'rcp');
                ?>
"><?php 
                echo rcp_is_recurring($member->ID) ? __('yes', 'rcp') : __('no', 'rcp');
                ?>
</td>
								<td data-colname="<?php 
                _e('Expiration', 'rcp');
                ?>
"><?php 
                echo $expiration;
                ?>
</td>
								<td data-colname="<?php 
                _e('User Role', 'rcp');
                ?>
"><?php 
                echo rcp_get_user_role($member->ID);
                ?>
</td>
								<?php 
                do_action('rcp_members_page_table_column', $member->ID);
                ?>
							</tr>
						<?php 
                $i++;
            }
        } else {
            ?>
						<tr><td colspan="6"><?php 
            _e('No subscribers found', 'rcp');
            ?>
</td></tr>
					<?php 
        }
        ?>
					</tbody>
					<tfoot>
						<tr>
							<td id="cb" class="manage-column column-cb check-column">
								<label class="screen-reader-text" for="cb-select-all-1"><?php 
        _e('Select All', 'rcp');
        ?>
</label>
								<input id="cb-select-all-1" type="checkbox">
							</td>
							<th scope="col" class="rcp-user-col manage-column column-primary"><?php 
        _e('User', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-sub-col manage-column"><?php 
        _e('Subscription', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-status-col manage-column"><?php 
        _e('Status', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-recurring-col manage-column"><?php 
        _e('Recurring', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-expiration-col manage-column"><?php 
        _e('Expiration', 'rcp');
        ?>
</th>
							<th scope="col" class="rcp-role-col manage-column"><?php 
        _e('User Role', 'rcp');
        ?>
</th>
							<?php 
        do_action('rcp_members_page_table_footer');
        ?>
						</tr>
					</tfoot>
				</table>
			</form>
			<?php 
        if ($total_pages > 1 && !isset($_GET['signup_method'])) {
            ?>
				<div class="tablenav bottom">
					<div class="tablenav-pages alignright">
						<?php 
            $query_string = $_SERVER['QUERY_STRING'];
            $base = 'admin.php?' . remove_query_arg('p', $query_string) . '%_%';
            echo paginate_links(array('base' => $base, 'format' => '&p=%#%', 'prev_text' => __('&laquo; Previous', 'rcp'), 'next_text' => __('Next &raquo;', 'rcp'), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5));
            ?>
					</div>
				</div><!--end .tablenav-->
			<?php 
        }
        ?>
			<?php 
        do_action('rcp_members_below_table');
        ?>
			<h3>
				<?php 
        _e('Add New Subscription (for existing user)', 'rcp');
        ?>
				<span alt="f223" class="rcp-help-tip dashicons dashicons-editor-help" title="<?php 
        _e('If you wish to create a brand new account, that may be done from Users &rarr; Add New. <br/><strong>Note</strong>: this will not create a payment profile for the member. That must be done manually through your merchant account.', 'rcp');
        ?>
"></span>
			</h3>
			<form id="rcp-add-new-member" action="" method="post">
				<table class="form-table">
					<tbody>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="rcp-username"><?php 
        _e('Username', 'rcp');
        ?>
</label>
							</th>
							<td>
								<input type="text" name="user" id="rcp-user" autocomplete="off" class="regular-text rcp-user-search" style="width: 120px;"/>
								<img class="rcp-ajax waiting" src="<?php 
        echo admin_url('images/wpspin_light.gif');
        ?>
" style="display: none;"/>
								<div id="rcp_user_search_results"></div>
								<p class="description"><?php 
        _e('Begin typing the user name to add a subscription to.', 'rcp');
        ?>
</p>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="rcp-level"><?php 
        _e('Subscription Level', 'rcp');
        ?>
</label>
							</th>
							<td>
								<select name="level" id="rcp-level">
									<option value="choose"><?php 
        _e('--choose--', 'rcp');
        ?>
</option>
									<?php 
        foreach (rcp_get_subscription_levels() as $level) {
            echo '<option value="' . $level->id . '">' . $level->name . '</option>';
        }
        ?>
								</select>
								<span alt="f223" class="rcp-help-tip dashicons dashicons-editor-help" title="<?php 
        _e('The subscription level determines the content the member has access to. <strong>Note</strong>: adding a subscription level to a member will not create a payment profile in your merchant account.', 'rcp');
        ?>
"></span>
								<p class="description"><?php 
        _e('Choose the subscription level for this user.', 'rcp');
        ?>
</p>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="rcp-expiration"><?php 
        _e('Expiration date', 'rcp');
        ?>
</label>
							</th>
							<td>
								<input name="expiration" id="rcp-expiration" type="text" style="width: 120px;" class="rcp-datepicker"/>
								<label for="rcp-unlimited">
									<input name="unlimited" id="rcp-unlimited" type="checkbox"/>
									<span class="description"><?php 
        _e('Never expires?', 'rcp');
        ?>
</span>
								</label>
								<p class="description"><?php 
        _e('Enter the expiration date for this user in the format of yyyy-mm-dd', 'rcp');
        ?>
</p>
							</td>
						</tr>
					</tbody>
				</table>
				<p class="submit">
					<input type="hidden" name="rcp-action" value="add-subscription"/>
					<input type="submit" value="<?php 
        _e('Add User Subscription', 'rcp');
        ?>
" class="button-primary"/>
				</p>
				<?php 
        wp_nonce_field('rcp_add_member_nonce', 'rcp_add_member_nonce');
        ?>
			</form>

		<?php 
    }
    ?>

	</div><!--end wrap-->

	<?php 
}