Para cambiar automáticamente a los usuarios a una suscripción gratuita cuando su cuenta caduque o se cancele, debe utilizar el sistema de notificaciones push para llamar a un script personalizado which would update the member’s account to be active on a free membership.
MemberMouse utiliza 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.
Aquí tienes un script de ejemplo que puedes utilizar como punto de partida:
<?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.
NOTA: Este script está dirigido a personas con experiencia en desarrollo. El equipo de atención al cliente de MemberMouse no puede proporcionar ninguna ayuda en relación con la interpretación o el uso de este 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.
A continuación crear una notificación push that’s triggered on the Cambios en la condición de miembro event. If you want it to occur when the membership Expires, then you would choose ‘Expired’ in the Cuando el estado de afiliación... menú desplegable.
La configuración sería más o menos así:
NOTA: If you want this to occur when the membership is Canceled, then choose ‘Canceled’ in the Cuando el estado de afiliación... menú desplegable.
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.

