public function createMember($rest)
 {
     $post = $rest->getRequest()->getPost();
     MM_LogApi::logRequest(json_encode($post), "/createMember");
     if (!Utils::isAuthenticated($post)) {
         return new Response($rest, null, RESPONSE_ERROR_MESSAGE_AUTH, RESPONSE_ERROR_CODE_AUTH, RESPONSE_ERROR_MESSAGE_AUTH);
     }
     $req = new stdClass();
     $req->membership_level_id = self::$REGEX_INTEGER_ONLY;
     $req->email = self::$REGEX_CONTAINS_EMAIL;
     $data = Utils::processApiRequestData($post, $req);
     if (MM_Response::isError($data)) {
         return new Response($rest, null, $data->message, RESPONSE_ERROR_CODE_MISSING_PARAMS, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     $result = MM_APIService::createMember($data);
     if (MM_Response::isSuccess($result)) {
         $user = MM_User::findByEmail($data->email);
         if (!$user->isValid()) {
             return new Response($rest, null, "Failed to create user with email address {$data->email}", RESPONSE_ERROR_CODE_CONFLICT, RESPONSE_ERROR_MESSAGE_CONFLICT);
         }
         $userData = array('member_id' => $user->getId(), 'username' => $user->getUsername(), 'email' => $user->getEmail(), 'password' => $user->getPassword(), 'confirmationUrl' => $result->getData(MM_Response::$DATA_KEY_URL));
         return new Response($rest, $userData, $userData);
     } else {
         return new Response($rest, null, $result->message, RESPONSE_ERROR_CODE_CONFLICT, RESPONSE_ERROR_MESSAGE_CONFLICT);
     }
 }
Beispiel #2
0
function processLogin($request, $provider)
{
    //don't attempt to login already logged in users
    if (MM_Utils::isLoggedIn()) {
        $loggedInUser = MM_Utils::getCurrentUser();
        $redirectUrl = isset($request['redirect_url']) ? $request['redirect_url'] : MM_CorePageEngine::getUrl(MM_CorePageType::$MEMBER_HOME_PAGE, null, $loggedInUser);
        wp_redirect($redirectUrl);
        exit;
    }
    //either login using a linked account, or using the email (if provided) by the social media account, with that order of precedence
    $authResponse = $provider->authenticate();
    if (!MM_Response::isSuccess($authResponse)) {
        //error authenticating
        throw new Exception("Error authenticating with social network", "1001015");
    }
    $profileResponse = $provider->getUserProfile();
    if (!MM_Response::isSuccess($profileResponse)) {
        //error retrieving profile
        throw new Exception("Error retrieving social network profile", "1001005");
    }
    $profile = $profileResponse->message;
    if (!isset($profile->identifier) || empty($profile->identifier)) {
        //invalid profile identifier
        throw new Exception("Error retrieving social network profile identier or identifier was invalid", "1001006");
    }
    $socialNetworkUniqueIdentifier = $profile->identifier;
    $userAccountResponse = $provider->findLinkedUserByIdentifier($socialNetworkUniqueIdentifier);
    if (MM_Response::isSuccess($userAccountResponse)) {
        $loginUser = $userAccountResponse->message;
    } else {
        if ($provider->getEmailHandlingStrategy() == MM_AbstractSocialLoginExtension::$EMAIL_PROVIDED) {
            //couldnt locate a linked account, either because it doesnt exist or there was an error, try using profile email
            $email = isset($profile->emailVerified) ? $profile->emailVerified : (isset($profile->email) ? $profile->email : "");
            if (empty($email)) {
                throw new Exception("Unable to login: account not linked and no user account found with the supplied email", "1001002");
            }
            $loginUser = MM_User::findByEmail($email);
            if (!$loginUser->isValid()) {
                throw new Exception("Unable to login: account not linked and no valid user account found with the supplied email", "1001003");
            }
        } else {
            throw new Exception("Unable to login: account not linked and provider doesn't supply email", "1001001");
        }
    }
    //we have the user now
    $userHooks = new MM_UserHooks();
    $redirectUrl = isset($request['redirect_url']) ? $request['redirect_url'] : MM_CorePageEngine::getUrl(MM_CorePageType::$MEMBER_HOME_PAGE, null, $loginUser);
    $userHooks->doAutoLogin($loginUser->getId(), $redirectUrl);
    //end login block
    exit;
}
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
global $current_user;
$user = new MM_User($current_user->ID);
$enableUsernameChange = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_ENABLE_USERNAME_CHANGE) == "1" ? true : false;
?>

<div id="mm-form-container">
<p class="mm-myaccount-dialog-section-header">Account Information</p>
<table>
	<tr>
		<td><span class="mm-myaccount-dialog-label">First Name</span></td>
		<td><input id="mm_first_name" name="mm_first_name" type="text" class="mm-myaccount-form-field" value="<?php 
echo $user->getFirstName();
?>
"/></td>
	</tr>
	<tr>
		<td><span class="mm-myaccount-dialog-label">Last Name</span></td>
		<td><input id="mm_last_name" name="mm_last_name" type="text" class="mm-myaccount-form-field" value="<?php 
echo $user->getLastName();
?>
"/></td>
	</tr>
	<tr>
		<td><span class="mm-myaccount-dialog-label">Phone</span></td>
Beispiel #4
0
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
MM_MemberMouseService::validateLicense(new MM_License());
$crntPage = MM_ModuleUtils::getPage();
$primaryTab = MM_ModuleUtils::getPrimaryTab();
$module = MM_ModuleUtils::getModule();
if (isset($_REQUEST[MM_Session::$PARAM_USER_ID])) {
    $user = new MM_User($_REQUEST[MM_Session::$PARAM_USER_ID]);
} else {
    $user = new MM_User();
}
$resourceUrl = MM_RESOURCES_URL;
if (MM_Utils::isSSL()) {
    $resourceUrl = preg_replace("/(http\\:)/", "https:", MM_RESOURCES_URL);
}
if (version_compare(get_bloginfo('version'), "3.8", ">=")) {
    ?>
<!-- override WordPress 3.8 styles -->
<style>
#wpwrap
{
	background-color: #fff;
}
.ui-widget 
{
	font-size:1em;
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
global $current_user;
$user = new MM_User($current_user->ID);
$fieldInfo = array();
$field = new stdClass();
$field->fieldId = "mm_field_billing_address";
$field->fieldName = "billingaddress";
$field->label = "Address";
$fieldInfo[] = $field;
$field = new stdClass();
$field->fieldId = "mm_field_billing_city";
$field->fieldName = "billingcity";
$field->label = "City";
$fieldInfo[] = $field;
$field = new stdClass();
$field->fieldId = "mm_field_billing_state";
$field->fieldName = "billingstate";
$field->label = "State";
$fieldInfo[] = $field;
$field = new stdClass();
$field->fieldId = "mm_field_billing_zip";
$field->fieldName = "billingzipcode";
$field->label = "Zip Code";
$fieldInfo[] = $field;
$field = new stdClass();
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
if (isset($_REQUEST[MM_Session::$PARAM_USER_ID])) {
    $user = new MM_User($_REQUEST[MM_Session::$PARAM_USER_ID]);
    if ($user->isValid()) {
        // check to make sure current employee has access to manage this member
        global $current_user;
        $employee = MM_Employee::findByUserId($current_user->ID);
        $allowAccess = true;
        if ($employee->isValid()) {
            $allowAccess = $employee->canManageMember($user);
        }
        if ($allowAccess) {
            include_once MM_MODULES . "/details.header.php";
            // prepare data grid
            $view = new MM_SubscriptionsView();
            $dataGrid = new MM_DataGrid($_REQUEST, "date_added", "desc", 10);
            $data = $view->getViewData($user->getId(), $dataGrid);
            $rows = $view->generateRows($data, true);
            $dataGrid->setTotalRecords($data);
            $dataGrid->recordName = "subscription";
            $nextRebillDateInfo = "Next rebill date is only available for subscriptions billed with a card-on-file payment service (i.e. Stripe, Braintree, Authorize.net CIM). When non-card-on-file payment services are used (i.e. PayPal, Authorize.net), the billing schedule is managed on their end so MemberMouse doesn't have access to the next rebill date.";
            $headers = array('date_added' => array('content' => '<a onclick="mmjs.sort(\'date_added\');" href="#">Start Date</a>', "attr" => "style='width:100px;'"), 'order_item_status' => array('content' => 'Status', "attr" => "style='width:50px;'"), 'access_type_name' => array('content' => 'Associated Access'), 'product_id' => array('content' => 'Product Name'), 'billing_description' => array('content' => 'Billing Description'), 'rebill_date' => array('content' => 'Next Rebill Date' . MM_Utils::getInfoIcon($nextRebillDateInfo), "attr" => "style='width:140px;'"), 'actions' => array('content' => 'Actions', "attr" => "style='width:90px;'"));
            $dataGrid->setHeaders($headers);
            $dataGrid->setRows($rows);
            $dgHtml = $dataGrid->generateHtml();
Beispiel #7
0
 function loginRedirect($redirectTo, $request, $user)
 {
     // clear login form session parameters
     MM_Session::clear(MM_Session::$KEY_LOGIN_FORM_USER_ID);
     MM_Session::clear(MM_Session::$KEY_LOGIN_FORM_USERNAME);
     $newRedirectTo = "";
     $allowUserOverride = true;
     if (class_exists("MM_CorePageEngine")) {
         if ($user instanceof WP_User && isset($user->data->ID) && intval($user->data->ID) > 0) {
             // check if this is an employee
             $employee = MM_Employee::findByUserId($user->data->ID);
             if ($employee->isValid()) {
                 MM_Preview::clearPreviewMode();
                 MM_Preview::getData();
                 $newRedirectTo = $employee->getHomepage();
             }
             if (empty($newRedirectTo)) {
                 $mmUser = new MM_User($user->data->ID);
                 if ($mmUser->getStatus() == MM_Status::$EXPIRED) {
                     $allowUserOverride = false;
                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_EXPIRED, $mmUser);
                     wp_logout();
                 } else {
                     if ($mmUser->getStatus() == MM_Status::$CANCELED) {
                         $allowUserOverride = false;
                         $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_CANCELED, $mmUser);
                         wp_logout();
                     } else {
                         if ($mmUser->getStatus() == MM_Status::$LOCKED) {
                             $allowUserOverride = false;
                             $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_LOCKED, $mmUser);
                             wp_logout();
                         } else {
                             if ($mmUser->getStatus() == MM_Status::$OVERDUE) {
                                 $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$MY_ACCOUNT, "", $mmUser);
                             } else {
                                 MM_Preview::clearPreviewMode();
                                 $setting = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_ON_LOGIN_USE_WP_FRONTPAGE);
                                 if ($setting == "1") {
                                     $newRedirectTo = MM_OptionUtils::getOption("siteurl");
                                 } else {
                                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$MEMBER_HOME_PAGE, "", $mmUser);
                                 }
                                 $lastAccessDeniedPageID = MM_Session::value(MM_OptionUtils::$OPTION_KEY_LAST_PAGE_DENIED);
                                 // check if current member has access to the last access denied page
                                 $pce = new MM_ProtectedContentEngine();
                                 if (intval($lastAccessDeniedPageID) > 0 && $pce->canAccessPost($lastAccessDeniedPageID, $mmUser->getId())) {
                                     $corePageEngine = new MM_CorePageEngine();
                                     if (!$corePageEngine->arePermalinksUsed()) {
                                         $newRedirectTo = get_page_link($lastAccessDeniedPageID);
                                     } else {
                                         $newRedirectTo = get_permalink($lastAccessDeniedPageID);
                                     }
                                 }
                                 MM_Session::clear(MM_OptionUtils::$OPTION_KEY_LAST_PAGE_DENIED);
                                 MM_ActivityLog::log($mmUser, MM_ActivityLog::$EVENT_TYPE_LOGIN);
                                 if ($mmUser->hasReachedMaxIPCount()) {
                                     global $current_user, $user;
                                     $mmUser->setStatus(MM_Status::$LOCKED);
                                     $mmUser->commitData();
                                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_LOCKED, $mmUser);
                                     wp_logout();
                                 }
                             }
                         }
                     }
                 }
                 if (empty($newRedirectTo)) {
                     $newRedirectTo = MM_OptionUtils::getOption("siteurl");
                 }
             }
         }
         // give customer an opportunity to redirect the user
         if ($allowUserOverride) {
             $currentUrl = !empty($newRedirectTo) ? $newRedirectTo : $redirectTo;
             $infoObj = new stdClass();
             $infoObj->currentUrl = $currentUrl;
             $infoObj->user = $user;
             $redirectOverride = apply_filters(MM_Filters::$LOGIN_REDIRECT, $infoObj);
             if (is_string($redirectOverride) && !empty($redirectOverride) && $redirectOverride != $currentUrl) {
                 if (!defined("DOING_AJAX") || !DOING_AJAX) {
                     wp_redirect($redirectOverride);
                     exit;
                 } else {
                     return $redirectOverride;
                 }
             }
         }
         if (!empty($newRedirectTo)) {
             return $newRedirectTo;
         }
         return $redirectTo;
     }
 }
 * (c) MemberMouse, LLC. All rights reserved.
 */
$view = new MM_PayPalIPNLogView();
if (!empty($_REQUEST["sortby"])) {
    $dataGrid = new MM_DataGrid($_REQUEST, $_REQUEST["sortby"], "desc", 20);
} else {
    $dataGrid = new MM_DataGrid($_REQUEST, "received", "desc", 20);
}
$data = $view->getViewData($_REQUEST, $dataGrid);
$dataGrid->setTotalRecords($data);
$dataGrid->recordName = "IPN";
$rows = array();
$headers = array();
foreach ($data as $key => $item) {
    // member link
    $user = new MM_User($item->user_id);
    $memberLink = MM_NO_DATA;
    if ($user->isValid()) {
        $memberLink = $user->getUsername();
        $memberLink = "<a href='?page=" . MM_MODULE_MANAGE_MEMBERS . "&module=details_general&user_id=" . $item->user_id . "'>" . $user->getUsername() . "</a>";
    }
    // order link
    $orderLink = MM_NO_DATA;
    if (!empty($item->order_number)) {
        $orderLink = "<span style='font-family:courier;'><a href='" . MM_ModuleUtils::getUrl(MM_MODULE_MANAGE_MEMBERS, MM_MODULE_MEMBER_DETAILS_TRANSACTION_HISTORY) . "&user_id={$item->user_id}'>{$item->order_number}</a></span>";
    }
    // IPN Details
    $ipnDetails = MM_NO_DATA;
    ?>
		<div id="mm-view-info-<?php 
    echo $item->id;
Beispiel #9
0
 /**
  * This function returns a user object based on if a member is logged in or an admin. If an 
  * admin is logged in, a user object will be returned based on the current preview bar settings
  */
 public static function getCurrentUser()
 {
     global $user, $current_user;
     $user_obj = null;
     if (MM_Employee::isEmployee()) {
         $previewObj = MM_Preview::getData();
         if ($previewObj !== false) {
             return $previewObj->getUser();
         }
     }
     if (isset($user->ID) && intval($user->ID) > 0) {
         $user_obj = MM_User::create($user->ID);
     } else {
         if (isset($user->data->ID) && intval($user->data->ID) > 0) {
             $user_obj = MM_User::create($user->data->ID);
         } else {
             if (isset($current_user->ID) && intval($current_user->ID) > 0) {
                 $user_obj = MM_User::create($current_user->ID);
             }
         }
     }
     return $user_obj;
 }
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
$user = new MM_User($p->userId);
if (!$user->isValid()) {
    // a new user is being so there create a pending account for them
    if (intval($p->userId) == MM_User::$NEW_USER_ID) {
        // the following fields in lastActionParams are defined in members.dialog.php/mm_members.js
        $lastParams = json_decode($p->lastActionParams);
        $user = new MM_User();
        $user->setStatus(MM_Status::$PENDING_ACTIVATION);
        $user->setStatusMessage("Customer account created by administrator using the Create Member tool but not completed.");
        $user->setMembershipId($lastParams->mm_new_membership);
        $user->setEmail($lastParams->mm_new_email);
        $user->setFirstName($lastParams->mm_new_first_name);
        $user->setLastName($lastParams->mm_new_last_name);
        if (isset($lastParams->mm_new_phone)) {
            $user->setPhone($lastParams->mm_new_phone);
        }
        if (isset($lastParams->mm_new_password)) {
            $user->setPassword($lastParams->mm_new_password);
        }
        $result = $user->commitData();
        if (MM_Response::isError($result)) {
            echo "Payment Options Dialog:  Error creating pending account for new member: {$result->message}";
            exit;
        }
Beispiel #11
0
<?php

/**
 *
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
global $current_user;
$memberTypeId = $p->member_type_id;
$user = new MM_User($current_user->ID);
$userMemberType = new MM_MembershipLevel($user->getMembershipId());
$memberType = new MM_MembershipLevel($memberTypeId);
$costOfNewMemberType = "Free";
if (!$memberType->isFree()) {
    $product = new MM_Product($memberType->getDefaultProduct());
    $costOfNewMemberType = "\$" . $product->getPrice(true);
}
$refund = "N/A";
$refundFloat = 0;
$currentMembershipPrice = "Free";
if (!$userMemberType->isFree()) {
    $existingProduct = new MM_Product($userMemberType->getDefaultProduct());
    if ($existingProduct->isValid()) {
        $currentMembershipPrice = "\$" . $existingProduct->getPrice(true);
    }
}
?>
<input type='hidden' id='mm-member-type-id' value='<?php 
echo $memberTypeId;
?>
' />
Beispiel #12
0
// define CSV headers
if ($doGenerateCsv) {
    $csvHeaders = array('ID', 'First Name', 'Last Name', 'Email', 'Phone', 'Membership Level', 'Bundles', 'Registered', 'Status Changed', 'Status', 'Billing Address', 'Billing City', 'Billing State', 'Billing Zip', 'Billing Country', 'Shipping Address', 'Shipping City', 'Shipping State', 'Shipping Zip', 'Shipping Country');
    $fields = MM_CustomField::getCustomFieldsList();
    foreach ($fields as $id => $val) {
        $customField = new MM_CustomField($id);
        if ($customField->isValid()) {
            $csvHeaders[] = $customField->getDisplayName();
        }
    }
    $csvRows = array($csvHeaders);
}
// process data
$bundleNames = array();
foreach ($data as $key => $item) {
    $user = new MM_User();
    $user->setId($item->id);
    $user->setFirstName($item->first_name);
    $user->setLastName($item->last_name);
    $user->setEmail($item->user_email);
    $user->setPhone($item->phone);
    $user->setRegistrationDate($item->user_registered);
    $user->setLastLoginDate($item->last_login_date);
    $user->setMembershipId($item->membership_level_id);
    $user->setStatus($item->status);
    if ($doGenerateCsv) {
        $user->setBillingAddress($item->billing_address1);
        $user->setBillingCity($item->billing_city);
        $user->setBillingState($item->billing_state);
        $user->setBillingZipCode($item->billing_postal_code);
        $user->setBillingCountry($item->billing_country);