{"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":"utilizar-la-interfaz-php","status":"publish","type":"ht_kb","link":"https:\/\/membermouse.com\/es\/docs\/utilizar-la-interfaz-php\/","title":{"rendered":"Uso de la interfaz PHP"},"content":{"rendered":"<p>MemberMouse le ofrece una amplia gama de&nbsp;<a href=\"https:\/\/membermouse.com\/es\/docs\/vision-general-de-smarttags\/\">SmartTags\u2122 (etiquetas inteligentes)<\/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>Todo esto es muy \u00fatil cuando trabajas con el editor de contenidos de WordPress, pero \u00bfqu\u00e9 pasa si quieres poder hacer todo esto con un script PHP personalizado?<\/p>\n\n\n\n<p>Aqu\u00ed es donde entra en juego la interfaz PHP.<\/p>\n\n\n\n<p><strong>NOTA<\/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\/es\/docs\/sistema-membermouse-y-requisitos-de-alojamiento\/\" target=\"_blank\" rel=\"noreferrer noopener\">Requisitos de sistema y alojamiento<\/a>\u00a0para obtener la informaci\u00f3n m\u00e1s actualizada.<\/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 de la interfaz PHP<\/h5>\n\n\n\n<p>Las funciones de interfaz PHP requieren acceso a las bibliotecas MemberMouse para funcionar. Cuando utiliza las funciones de interfaz PHP dentro de una plantilla de WordPress, estas bibliotecas se cargan autom\u00e1ticamente. Sin embargo, si desea utilizarlas dentro de un script PHP independiente, tendr\u00e1 que cargar manualmente las bibliotecas MemberMouse a\u00f1adiendo los siguientes includes al principio de su archivo: <\/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>Si su script se encuentra en el directorio ra\u00edz de WordPress, entonces puede utilizar los includes exactamente como se presentan arriba. Si el script se encuentra en otro directorio, deber\u00e1 actualizar las rutas de los archivos.<\/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>Los atributos se pasan a las funciones de la interfaz PHP como una matriz asociativa. <\/p>\n\n\n\n<p>He aqu\u00ed un par de ejemplos: <\/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\/es\/docs\/vision-general-de-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;devuelven una cadena con los datos solicitados.<\/p>\n\n\n\n<p><code>mm_..._enlace()<\/code>&nbsp;devuelven una cadena que contiene una URL o una funci\u00f3n javascript que debe colocarse dentro de un archivo&nbsp;<code>&lt;a&gt;<\/code>&nbsp;etiqueta o&nbsp;<code>&lt;button&gt;<\/code>&nbsp;para convertirlo en un enlace funcional.<\/p>\n\n\n\n<p><code>mm_..._decisi\u00f3n()<\/code>&nbsp;las funciones devuelven&nbsp;<code>verdadero<\/code>&nbsp;o&nbsp;<code>falso<\/code>&nbsp;en funci\u00f3n de los atributos pasados a la funci\u00f3n y del contexto en el que se ejecuta.<\/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\">Ejemplos<\/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\">descargar el script de ejemplo<\/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\/es\/wp-json\/wp\/v2\/ht-kb\/8069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/users\/21411"}],"replies":[{"embeddable":true,"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/comments?post=8069"}],"version-history":[{"count":1,"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/ht-kb\/8069\/revisions"}],"predecessor-version":[{"id":21354,"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/ht-kb\/8069\/revisions\/21354"}],"wp:attachment":[{"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/media?parent=8069"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/ht-kb-category?post=8069"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/membermouse.com\/es\/wp-json\/wp\/v2\/ht-kb-tag?post=8069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}