Afin de faire passer automatiquement les membres à une adhésion gratuite lorsque leur compte expire ou est annulé, vous devez utiliser le système de notification push pour appeler un script personnalisé which would update the member’s account to be active on a free membership.
Utilisation de MemberMouse WordPress’ built-in cron function to check two times a day for any accounts that should be expired. WordPress’ cron is triggered by traffic coming to the site so if you have minimal traffic coming to the site, the period of time in between when it’s executed may be less frequent than two times per day. Any activity on the site will trigger the cron to run, so if you have minimal traffic and notice it hasn’t run, simply visit any page on your site to initiate it.
Voici un exemple de script que vous pouvez utiliser comme point de départ :
<?php
// ===> TODO make sure this script is placed in the same directory as wp-load.php or if you put it somewhere else
// make sure to update the paths below
require_once("wp-load.php");
require_once("wp-content/plugins/membermouse/includes/mm-constants.php");
require_once("wp-content/plugins/membermouse/includes/init.php");
// ================= START CUSTOMIZATION ====================================
// If you need help finding your API URL, key or secret, read this article:
// http://support.membermouse.com/support/solutions/articles/9000020340-api-credentials-overview
// Your API URL
$apiUrl = "http://yourdomain.com/wp-content/plugins/membermouse/api/request.php";
// Your API key
$apiKey = "abc123def456";
// Your API secret
$apiSecret = "abc123def456";
// If you need help finding the membership level ID, read this article:
// http://support.membermouse.com/support/solutions/articles/9000020396-finding-ids-for-membership-levels-products-and-bundles
// The ID of the free membership level to switch the member to
$freeMembershipLevelId = 1;
// ================= END CUSTOMIZATION ======================================
// ==========================================================================
if(!isset($_GET["member_id"]) || empty($_GET["member_id"]))
{
exit;
}
$memberId = $_GET["member_id"];
$inputParams = "apikey={$apiKey}&apisecret={$apiSecret}&";
$inputParams .= "member_id={$memberId}&";
$inputParams .= "status=1&";
$inputParams .= "membership_level_id={$freeMembershipLevelId}&";
$apiCallUrl = "{$apiUrl}?q=/updateMember";
$ch = curl_init($apiCallUrl);
// ================= User Agent Header
$headers = array(
'Referrer: ' . site_url(),
'User-Agent: ' . MM_CURL_USER_AGENT,
);
// ================= End User Agent Header
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $inputParams);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
echo "<pre>".print_r($result, true)."</pre>";
?>
This script will change the members membership level to the one indicated in the script and set their status to ‘Active’. In order for the script to work you need to provide your API information and the appropriate membership level ID. Additional instructions can be found in the comments in the script.
NOTE : Ce script est destiné aux personnes ayant une expérience en matière de développement. L'équipe chargée de la réussite des clients de MemberMouse ne peut fournir aucune assistance concernant l'interprétation ou l'utilisation de ce script.
After you modified the script as needed, download it and save it. In this example, we suggest to save it under the name: free-member-downgrade.php
Next, upload it to your server within the public_html.
Ensuite, vous devez créer une notification push that’s triggered on the Changement du statut des membres event. If you want it to occur when the membership Expires, then you would choose ‘Expired’ in the Lorsque le statut de membre est... menu déroulant.
La configuration ressemblerait à quelque chose comme ceci :
NOTE : If you want this to occur when the membership is Canceled, then choose ‘Canceled’ in the Lorsque le statut de membre est... menu déroulant.
You should run some tests to ensure that everything is working correctly. In order to do this you’ll need to use a test member account to recreate the scenario where their account becomes expired or canceled. If everything is setup correctly, this should result in the test account remaining active on a free membership level.

