{"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\/using-the-php-interface\/","title":{"rendered":"Uso de la interfaz PHP"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">MemberMouse provides you with a wide range of&nbsp;<a href=\"https:\/\/membermouse.com\/docs\/smarttags-overview\/\">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 class=\"wp-block-paragraph\">This is all very helpful when you're working within WordPress' content editor, but what if you want to be able to do all of this within a custom PHP script?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is where the PHP Interface comes in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>NOTE<\/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\/docs\/membermouse-system-and-hosting-requirements\/\" target=\"_blank\" rel=\"noreferrer noopener\">System and Hosting Requirements<\/a>\u00a0for the most up-to-date information.<\/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\">PHP Interface Requirements<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">The PHP interface functions require access to MemberMouse libraries in order to work. When you use the PHP interface functions within a WordPress template, these libraries are automatically loaded. However, if you want to use them within a standalone PHP script, you'll need to manually load the MemberMouse libraries by adding the following includes to the top of your file: <\/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 class=\"wp-block-paragraph\">If your script is located in the root WordPress directory then you can use the includes exactly as they're presented above. If your script is located in another directory then you need to update the file paths appropriately.<\/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 class=\"wp-block-paragraph\">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 class=\"wp-block-paragraph\">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>&#91;MM_Member_Data name='email']\n&#91;MM_Member_Decision membershipId='2|3']...&#91;\/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 class=\"wp-block-paragraph\">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 class=\"wp-block-paragraph\">So for example,&nbsp;[ MM_Order_Data ] becomes mm_order_data ( ).&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You pass attributes to PHP Interface functions as an associative array. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are a couple of examples: <\/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 class=\"wp-block-paragraph\">The PHP Interface function accepts all of the same attributes as the SmartTag\u2122 itself. Refer to the&nbsp;<a href=\"https:\/\/membermouse.com\/docs\/smarttags-overview\/\">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\">Return Values<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\"><code>mm_..._data()<\/code>&nbsp;functions return a string containing the requested data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>mm_..._link()<\/code>&nbsp;functions return a string containing a URL or javascript function that should be placed within a&nbsp;<code>&lt;a&gt;<\/code>&nbsp;tag or&nbsp;<code>&lt;button&gt;<\/code>&nbsp;tag to make it a functional link.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>mm_..._decision()<\/code>&nbsp;functions return&nbsp;<code>true<\/code>&nbsp;or&nbsp;<code>false<\/code>&nbsp;based on the attributes passed to the function and the context in which it is run.<\/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\">Examples<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">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\">download the sample script<\/a>.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","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}]}}