MemberMouse bietet Ihnen eine breite Palette von SmartTags™. you can use to create a dynamic experience for your members. There are SmartTags™ 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!
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?
An dieser Stelle kommt die PHP-Schnittstelle ins Spiel.
ANMERKUNG: MemberMouse currently requires a minimum of PHP 7.4. We recommend the latest version of the PHP branch. Please see our System- und Hosting-Anforderungen um die aktuellsten Informationen zu erhalten.
Anforderungen an die PHP-Schnittstelle
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:
require_once("wp-load.php");
require_once("wp-content/plugins/membermouse/includes/mm-constants.php");
require_once("wp-content/plugins/membermouse/includes/init.php");
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.
Translating SmartTags™ in PHP Functions
With MemberMouse’s PHP Interface you can utilize MemberMouse SmartTags™ 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™ are supported through the PHP Interface with the exception of MM_Form… and MM_Error… SmartTags™.
When using SmartTags™ within the WordPress content editor the following syntax is used:
[MM_Mitglied_Daten name='email']
[MM_Member_Decision membershipId='2|3']...[/MM_Member_Decision]
SmartTags™ are transformed into their PHP interface equivalent by taking the SmartTag™ name, making it all lowercase, and adding parenthesis to make it a valid PHP function.
So for example, [ MM_Order_Data ] becomes mm_order_data ( ).
Sie übergeben Attribute an PHP-Schnittstellenfunktionen als assoziatives Array.
Hier sind einige Beispiele:
mm_member_data(array("name"=>"email"))
mm_member_decision(array("isMember"=>"true", "membershipId"=>"2|3"))
The PHP Interface function accepts all of the same attributes as the SmartTag™ itself. Refer to the SmartTag™ documentation for a list of attributes by SmartTag™.
Rückgabewerte
mm_..._data() Funktionen geben eine Zeichenkette zurück, die die angeforderten Daten enthält.
mm_..._link() Funktionen geben einen String zurück, der eine URL oder eine Javascript-Funktion enthält, die innerhalb einer <a> Tag oder Tag, um ihn zu einem funktionalen Link zu machen.
mm_..._Entscheidung() Funktionsrückgabe wahr oder falsch auf der Grundlage der an die Funktion übergebenen Attribute und des Kontexts, in dem sie ausgeführt wird.
Beispiele
To see examples of how each SmartTag™ can be used in PHP, das Beispielskript herunterladen.

