1. Início
  2. Base de conhecimento
  3. Dicas, truques e personalizações
  4. Dicas e truques
  5. Faça o downgrade automático para uma associação gratuita quando uma conta expirar ou for cancelada

Faça o downgrade automático para uma associação gratuita quando uma conta expirar ou for cancelada

Para mudar automaticamente os membros para uma associação gratuita quando a conta deles expirar/cancelar, você usaria o sistema de notificação por push para chamar um script personalizado which would update the member’s account to be active on a free membership.

Utilizações do 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.

Aqui está um exemplo de script que você pode usar como ponto 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.

OBSERVAÇÃO: Este script é destinado a pessoas com experiência em desenvolvimento. A Equipe de Sucesso do Cliente do MemberMouse não pode fornecer nenhum suporte em relação à interpretação ou ao uso desse 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.

Em seguida, você deve criar uma notificação por push that’s triggered on the Mudança de status de associação event. If you want it to occur when the membership Expires, then you would choose ‘Expired’ in the Quando o status de membro é... menu suspenso.

A configuração seria mais ou menos assim:



OBSERVAÇÃO: If you want this to occur when the membership is Canceled, then choose ‘Canceled’ in the Quando o status de membro é... menu suspenso.

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.

Este artigo foi útil?

Artigos relacionados

Não consegue encontrar a resposta que está procurando?

Entre em contato com nossa Equipe de Sucesso do Cliente
Entre em contato conosco!