Esempio n. 1
0
</p>


<h2>[MM_Member_Decision]</h2>

<!-- NOTE: The membershidId attribute should be changed to a valid Membership Level ID from your MemberMouse site. -->
<p>
	Is the current visitor a member? 
	<?php 
echo mm_member_decision(array("isMember" => "true")) == true ? "Yes" : "No";
?>
</p>
<p>
	Is the current member signed up for the membership level with ID 2?
	<?php 
echo mm_member_decision(array("membershipId" => "2")) == true ? "Yes" : "No";
?>
</p>


<h2>[MM_Order_Decision]</h2>

<!-- NOTE: Order decisions can only be used within checkout forms and on confirmation core pages. -->
<p>
	Is the current order shippable? 
	<?php 
echo mm_order_decision(array("isShippable" => "true")) == true ? "Yes" : "No";
?>
</p>
<p>
	Is the customer purchasing product ID 2?
 /**
  * Callback function to intercept and validate SSO requests
  * @return [type] [description]
  */
 public function interceptSSORequest()
 {
     if (isset($_GET['sso']) && isset($_GET['sig'])) {
         $varsso = $_GET['sso'];
         $varsig = $_GET['sig'];
         if (!$this->validate($varsso, $varsig)) {
             //return;
         }
         // Check to see whether the user is logged in or not
         if (!is_user_logged_in()) {
             // Preserve sso and sig parameters
             $redirect = add_query_arg(array('sso' => urlencode($varsso), 'sig' => urlencode($varsig)));
             // Change %0A to %0B so it's not stripped out in wp_sanitize_redirect
             $redirect = $this->cleansePayload($redirect);
             // Build login URL
             $login = wp_login_url(esc_url_raw($redirect));
             // Redirect to login
             wp_redirect($login);
             exit;
         } else {
             $allowedToLogin = true;
             if (is_plugin_active('membermouse/index.php')) {
                 if (pt_wp_sso_get_option('block_membermouse_free', 'pt_wp_sso_mm_settings') == 'on') {
                     if (mm_member_decision(array("isFree" => "true"))) {
                         $allowedToLogin = false;
                     }
                 }
             }
             if ($allowedToLogin) {
                 $ssopayload = $this->restorePayload($_GET['sso']);
                 $sigpayload = $_GET['sig'];
                 if (!$this->validate($ssopayload, $sigpayload)) {
                     // Error message
                     echo 'Invalid request.';
                     // Terminate
                     exit;
                 }
                 // Nonce
                 $nonce = $this->getNonce($ssopayload);
                 $current_user = wp_get_current_user();
                 // Map information
                 $params = array('nonce' => $nonce, 'name' => $current_user->display_name, 'username' => $current_user->user_login, 'email' => $current_user->user_email, 'about_me' => $current_user->description, 'external_id' => $current_user->ID, 'avatar_url' => self::get_avatar_url($current_user->ID));
                 // Build login string
                 $q = $this->buildLoginString($params);
                 // Redirect back to Discourse
                 wp_redirect($this->discourse_url . '/session/sso_login?' . $q);
             } else {
                 //redirect to home
                 wp_redirect(home_url());
             }
             exit;
         }
     }
 }