Um Mitglieder automatisch auf eine kostenlose Mitgliedschaft umzustellen, wenn ihr Konto abläuft/gekündigt wird, würden Sie das Push-Benachrichtigungssystem verwenden, um ein benutzerdefiniertes Skript aufrufen which would update the member’s account to be active on a free membership.
MitgliedMaus nutzt 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.
Hier finden Sie ein Beispielskript, das Sie als Ausgangspunkt verwenden können:
<?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.
HINWEIS: Dieses Skript ist für Personen mit Entwicklungserfahrung gedacht. Das MemberMouse Customer Success Team kann keine Unterstützung in Bezug auf die Auslegung oder Verwendung dieses Skripts leisten.
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.
Als nächstes würden Sie eine Push-Benachrichtigung erstellen that’s triggered on the Status der Mitgliedschaft geändert event. If you want it to occur when the membership Expires, then you would choose ‘Expired’ in the Wenn der Mitgliedsstatus... Dropdown-Menü.
Der Aufbau würde in etwa so aussehen:
HINWEIS: If you want this to occur when the membership is Canceled, then choose ‘Canceled’ in the Wenn der Mitgliedsstatus... Dropdown-Menü.
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.

