{"id":7438,"date":"2023-08-11T08:47:35","date_gmt":"2023-08-11T15:47:35","guid":{"rendered":"https:\/\/membermouse.com\/?post_type=ht_kb&#038;p=7438"},"modified":"2025-04-03T14:46:56","modified_gmt":"2025-04-03T18:46:56","slug":"retrograder-automatiquement-vers-une-adhesion-gratuite","status":"publish","type":"ht_kb","link":"https:\/\/membermouse.com\/fr\/documents-3-2\/retrograder-automatiquement-vers-une-adhesion-gratuite\/","title":{"rendered":"R\u00e9trograder automatiquement vers une adh\u00e9sion gratuite lorsqu'un compte expire ou est annul\u00e9"},"content":{"rendered":"<p>Afin de faire passer automatiquement les membres \u00e0 une adh\u00e9sion gratuite lorsque leur compte expire ou est annul\u00e9, vous devez utiliser le syst\u00e8me de notification push pour&nbsp;<a href=\"https:\/\/membermouse.com\/fr\/documents-3-2\/appeler-un-script-personnalise-lorsque-certains-evenements-se-produisent\/\">appeler un script personnalis\u00e9<\/a>&nbsp;ce qui mettrait \u00e0 jour le compte du membre pour qu'il soit actif dans le cadre d'une adh\u00e9sion gratuite. <\/p>\n\n\n\n<p>Utilisation de MemberMouse&nbsp;<a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_cron\">La fonction cron int\u00e9gr\u00e9e de WordPress<\/a>&nbsp;to check&nbsp;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.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Voici un exemple de script que vous pouvez utiliser comme point de d\u00e9part :<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ ===> TODO make sure this script is placed in the same directory as wp-load.php or if you put it somewhere else\n\/\/ make sure to update the paths below\nrequire_once(\"wp-load.php\");\nrequire_once(\"wp-content\/plugins\/membermouse\/includes\/mm-constants.php\");\nrequire_once(\"wp-content\/plugins\/membermouse\/includes\/init.php\");\n \n\/\/ ================= START CUSTOMIZATION ====================================\n \n\/\/ If you need help finding your API URL, key or secret, read this article:\n\/\/ http:\/\/support.membermouse.com\/support\/solutions\/articles\/9000020340-api-credentials-overview\n\n\/\/ Your API URL\n$apiUrl = \"http:\/\/yourdomain.com\/wp-content\/plugins\/membermouse\/api\/request.php\";\n\n\/\/ Your API key\n$apiKey = \"abc123def456\";\n\n\/\/ Your API secret\n$apiSecret = \"abc123def456\"; \n\n\/\/ If you need help finding the membership level ID, read this article:\n\/\/ http:\/\/support.membermouse.com\/support\/solutions\/articles\/9000020396-finding-ids-for-membership-levels-products-and-bundles\n\n\/\/ The ID of the free membership level to switch the member to\n$freeMembershipLevelId = 1;\n\n\/\/ ================= END CUSTOMIZATION ======================================\n\/\/ ==========================================================================\n\nif(!isset($_GET&#91;\"member_id\"]) || empty($_GET&#91;\"member_id\"]))\n{\n\texit;\n}\n\n$memberId = $_GET&#91;\"member_id\"];\n\n$inputParams = \"apikey={$apiKey}&apisecret={$apiSecret}&\";\n$inputParams .= \"member_id={$memberId}&\";\n$inputParams .= \"status=1&\";\n$inputParams .= \"membership_level_id={$freeMembershipLevelId}&\";\n\n\n$apiCallUrl = \"{$apiUrl}?q=\/updateMember\";\n$ch = curl_init($apiCallUrl);\n\n\/\/ ================= User Agent Header\n$headers = array(\n    'Referrer: ' . site_url(),\n    'User-Agent: ' . MM_CURL_USER_AGENT,\n);\n\/\/ ================= End User Agent Header\n\ncurl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $inputParams);\ncurl_setopt($ch, CURLOPT_HEADER, 0);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n$result = curl_exec($ch);\ncurl_close($ch);\n\necho \"&lt;pre>\".print_r($result, true).\"&lt;\/pre>\";\n?><\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Ce script modifiera le niveau d'adh\u00e9sion du membre pour le remplacer par celui indiqu\u00e9 dans le script et d\u00e9finira son statut sur \"Actif\". Pour que le script fonctionne, vous devez fournir vos informations API et l'identifiant du niveau d'adh\u00e9sion appropri\u00e9. Des instructions suppl\u00e9mentaires peuvent \u00eatre trouv\u00e9es dans les commentaires du script.<\/p>\n\n\n\n<p><strong>NOTE :<\/strong>&nbsp;Ce script est destin\u00e9 aux personnes ayant une exp\u00e9rience en mati\u00e8re de d\u00e9veloppement. L'\u00e9quipe charg\u00e9e de la r\u00e9ussite des clients de MemberMouse ne peut fournir aucune assistance concernant l'interpr\u00e9tation ou l'utilisation de ce script.<\/p>\n\n\n\n<p>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<br><br>Next, upload it to your server within the public_html.<\/p>\n\n\n\n<p>Ensuite, vous devez&nbsp;<a href=\"https:\/\/membermouse.com\/fr\/documents-3-2\/utiliser-les-notifications-push\/\">cr\u00e9er une notification push<\/a>&nbsp;qui est d\u00e9clench\u00e9e sur le&nbsp;<em>Changement du statut des membres<\/em>&nbsp;\u00e9v\u00e9nement. Si vous souhaitez que l'\u00e9v\u00e9nement se produise \u00e0 l'expiration de l'adh\u00e9sion, vous devez choisir \"Expir\u00e9\" dans le champ&nbsp;<em>Lorsque le statut de membre est...<\/em>&nbsp;menu d\u00e9roulant.<\/p>\n\n\n\n<p>La configuration ressemblerait \u00e0 quelque chose comme ceci :<br><br><img decoding=\"async\" class=\"wp-image-11177\" style=\"width: 550px;\" src=\"https:\/\/storage.googleapis.com\/wpgcbucket\/wp\/2023\/10\/02c8db59-free-member-downgrade.png\" alt=\"\"><br><br><\/p>\n\n\n\n<p><strong>NOTE :<\/strong>&nbsp;Si vous souhaitez que cela se produise lorsque l'adh\u00e9sion est annul\u00e9e, choisissez \"Annul\u00e9\" dans le champ de saisie.&nbsp;<em>Lorsque le statut de membre est...<\/em>&nbsp;menu d\u00e9roulant.<\/p>\n\n\n\n<p>Vous devez effectuer quelques tests pour vous assurer que tout fonctionne correctement. Pour ce faire, vous devez utiliser un compte de membre test afin de recr\u00e9er le sc\u00e9nario dans lequel le compte expire ou est annul\u00e9. Si tout est configur\u00e9 correctement, le compte test devrait rester actif \u00e0 un niveau d'adh\u00e9sion gratuit.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Afin de faire passer automatiquement les membres \u00e0 une adh\u00e9sion gratuite lorsque leur compte expire ou est annul\u00e9, vous devez utiliser le syst\u00e8me de notification push pour appeler un script personnalis\u00e9...<\/p>","protected":false},"author":9645,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"om_disable_all_campaigns":false,"_strive_editorial_status":"not-started","_strive_copy_of":0,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"ht-kb-category":[138],"ht-kb-tag":[],"class_list":["post-7438","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-tips-tricks"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb\/7438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/users\/9645"}],"replies":[{"embeddable":true,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/comments?post=7438"}],"version-history":[{"count":2,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb\/7438\/revisions"}],"predecessor-version":[{"id":21043,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb\/7438\/revisions\/21043"}],"wp:attachment":[{"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/media?parent=7438"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb-category?post=7438"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb-tag?post=7438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}