{"id":8069,"date":"2023-08-14T14:19:55","date_gmt":"2023-08-14T21:19:55","guid":{"rendered":"https:\/\/membermouse.com\/?post_type=ht_kb&#038;p=8069"},"modified":"2025-10-20T10:20:50","modified_gmt":"2025-10-20T14:20:50","slug":"usando-a-interface-php","status":"publish","type":"ht_kb","link":"https:\/\/membermouse.com\/pt\/documentos-3-2\/usando-a-interface-php\/","title":{"rendered":"Usando a interface PHP"},"content":{"rendered":"<p>O MemberMouse oferece a voc\u00ea uma ampla gama de&nbsp;<a href=\"https:\/\/membermouse.com\/pt\/documentos-3-2\/visao-geral-das-smarttags\/\">SmartTags\u2122<\/a>&nbsp;you can use to create a dynamic experience for your members. There are SmartTags\u2122 that display the current member's name, email address, and other information. There are tags you can use to allow members to manage their subscriptions, others to change content based on the current member's access rights, and a lot more!<\/p>\n\n\n\n<p>Tudo isso \u00e9 muito \u00fatil quando voc\u00ea est\u00e1 trabalhando no editor de conte\u00fado do WordPress, mas e se voc\u00ea quiser fazer tudo isso em um script PHP personalizado?<\/p>\n\n\n\n<p>\u00c9 aqui que entra a interface PHP.<\/p>\n\n\n\n<p><strong>OBSERVA\u00c7\u00c3O<\/strong>: MemberMouse currently requires a minimum of PHP 7.4. We recommend the latest version of the PHP branch. Please see our\u00a0<a href=\"https:\/\/membermouse.com\/pt\/documentos-3-2\/sistema-membermouse-e-requisitos-de-hospedagem\/\" target=\"_blank\" rel=\"noreferrer noopener\">Requisitos de sistema e hospedagem<\/a>\u00a0para obter as informa\u00e7\u00f5es mais atualizadas.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Requisitos da interface PHP<\/h5>\n\n\n\n<p>As fun\u00e7\u00f5es da interface PHP requerem acesso \u00e0s bibliotecas do MemberMouse para funcionar. Quando voc\u00ea usa as fun\u00e7\u00f5es de interface PHP em um modelo do WordPress, essas bibliotecas s\u00e3o carregadas automaticamente. No entanto, se quiser us\u00e1-las em um script PHP aut\u00f4nomo, ser\u00e1 necess\u00e1rio carregar manualmente as bibliotecas do MemberMouse adicionando as seguintes inclus\u00f5es \u00e0 parte superior do arquivo: <\/p>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>require_once(\"wp-load.php\");\nrequire_once(\"wp-content\/plugins\/membermouse\/includes\/mm-constants.php\");;\nrequire_once(\"wp-content\/plugins\/membermouse\/includes\/init.php\");<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Se o seu script estiver localizado no diret\u00f3rio raiz do WordPress, voc\u00ea poder\u00e1 usar os includes exatamente como foram apresentados acima. Se o seu script estiver localizado em outro diret\u00f3rio, ser\u00e1 necess\u00e1rio atualizar os caminhos dos arquivos adequadamente.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Translating SmartTags\u2122 in PHP Functions<\/h5>\n\n\n\n<p>With MemberMouse's PHP Interface you can utilize MemberMouse SmartTags\u2122 right within a custom PHP script. You can use any WordPress plugin for executing PHP (i.e. PHP Exec) to use the PHP Interface functions right within the WordPress content editor. All SmartTags\u2122 are supported through the PHP Interface with the exception of&nbsp;MM_Form&#8230;&nbsp;and&nbsp;MM_Error&#8230;&nbsp;SmartTags\u2122.<\/p>\n\n\n\n<p>When using SmartTags\u2122 within the WordPress content editor the following syntax is used: <\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>[MM_Member_Data name='email']\n[MM_Member_Decision membershipId='2|3']...[\/MM_Member_Decision]<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>SmartTags\u2122 are transformed into their PHP interface equivalent by taking the SmartTag\u2122 name, making it all lowercase, and adding parenthesis to make it a valid PHP function. <\/p>\n\n\n\n<p>So for example,&nbsp;[ MM_Order_Data ] becomes mm_order_data ( ).&nbsp;<\/p>\n\n\n\n<p>Voc\u00ea passa atributos para as fun\u00e7\u00f5es da interface PHP como uma matriz associativa. <\/p>\n\n\n\n<p>Aqui est\u00e3o alguns exemplos: <\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>mm_member_data(array(\"name\"=&gt;\"email\"))\nmm_member_decision(array(\"isMember\"=&gt;\"true\", \"membershipId\"=&gt;\"2|3\"))<\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The PHP Interface function accepts all of the same attributes as the SmartTag\u2122 itself. Refer to the&nbsp;<a href=\"https:\/\/membermouse.com\/pt\/documentos-3-2\/visao-geral-das-smarttags\/\">SmartTag\u2122 documentation<\/a>&nbsp;for a list of attributes by SmartTag\u2122.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Valores de retorno<\/h5>\n\n\n\n<p><code>mm_..._data()<\/code>&nbsp;retornam uma cadeia de caracteres que cont\u00e9m os dados solicitados.<\/p>\n\n\n\n<p><code>mm_..._link()<\/code>&nbsp;retornam uma string contendo um URL ou uma fun\u00e7\u00e3o javascript que deve ser colocada em um&nbsp;<code>&lt;a&gt;<\/code>&nbsp;tag ou&nbsp;<code><button><\/code>&nbsp;para torn\u00e1-lo um link funcional.<\/p>\n\n\n\n<p><code>mm_..._decision()<\/code>&nbsp;retorno de fun\u00e7\u00f5es&nbsp;<code>verdadeiro<\/code>&nbsp;ou&nbsp;<code>falso<\/code>&nbsp;com base nos atributos passados para a fun\u00e7\u00e3o e no contexto em que ela \u00e9 executada.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Exemplos<\/h5>\n\n\n\n<p>To see examples of how each SmartTag\u2122 can be used in PHP,&nbsp;<a href=\"https:\/\/drive.google.com\/file\/d\/1n2Cee8PP5Hgu4S3RpRhMoor7mAEOr4tj\/view?usp=drive_link\">Fa\u00e7a o download do script de amostra<\/a>.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>","protected":false},"excerpt":{"rendered":"<p>MemberMouse provides you with a wide range of&nbsp;SmartTags\u2122&nbsp;you can use to create a dynamic experience for your members. There are SmartTags\u2122 that display the current member&#8217;s name, email address, and&#8230;<\/p>","protected":false},"author":21411,"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":[187],"ht-kb-tag":[],"class_list":["post-8069","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-mm-php"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/ht-kb\/8069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/users\/21411"}],"replies":[{"embeddable":true,"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/comments?post=8069"}],"version-history":[{"count":1,"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/ht-kb\/8069\/revisions"}],"predecessor-version":[{"id":21354,"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/ht-kb\/8069\/revisions\/21354"}],"wp:attachment":[{"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/media?parent=8069"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/ht-kb-category?post=8069"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/membermouse.com\/pt\/wp-json\/wp\/v2\/ht-kb-tag?post=8069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}