Esempio n. 1
0
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
$employee = new MM_Employee($p->id);
$disableRole = "";
global $current_user;
// employees can't edit their own role
if ($current_user->ID == $employee->getUserId()) {
    $disableRole = "disabled='disabled'";
}
?>
<div id="mm-form-container">
	<table cellspacing="10">
		<tr>
			<td colspan="2">
			<span style="font-size:11px;">
			Employee accounts are used to grant access to additional members of your team. Once the 
			account has been created, the employee can login with the email address and password associated with the account.</span>
			</td>
		</tr>
		<tr>
			<td>Role</td>
			<td>
				<select id='mm-role-id' <?php 
echo $disableRole;
?>
 onchange="mmjs.toggleAccessRestrictions();">
Esempio n. 2
0
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
// Attempt to correct any invalid employees. Otherwise, delete invalid accounts
global $wpdb;
$sql = "SELECT ea.* FROM " . MM_TABLE_EMPLOYEE_ACCOUNTS . " ea LEFT JOIN {$wpdb->users} u ON (ea.user_id = u.ID) " . "where ((ea.user_id IS NULL) OR (u.ID IS NULL))";
$results = $wpdb->get_results($sql);
$invalid_account_ids = array();
if ($wpdb->num_rows > 0) {
    //either these accounts are not linked or the user_id is not valid (user with that ID does not exist in WP)
    foreach ($results as $nullAccount) {
        $currentAccount = new MM_Employee($nullAccount->id);
        if ($currentAccount->isValid()) {
            $currentAccount->commitData();
            //the commit logic will clean up any invalid links
            if ($currentAccount->getUserId() instanceof WP_Error || $currentAccount->getUserId() <= 0) {
                $invalid_account_ids[] = $currentAccount->getId();
            }
        }
    }
}
if (count($invalid_account_ids) > 0) {
    $successfully_deleted_accounts = array();
    // attempt to delete all invalid accounts
    for ($i = 0; $i < count($invalid_account_ids); $i++) {
        $account = new MM_Employee($invalid_account_ids[$i]);
        if ($account->isValid()) {
            $userEmail = $account->getEmail();
            $response = $account->delete();
            // if account was deleted successfully, store it in $successfully_deleted_accounts
            if ($response) {