Making a custom add-on This page guides you into developing your own add-on to safely modify AcyMailing features.
AcyMailing has a lot of features, but it isn't integrated with every other extension. You may want to create your own custom add-on to:
insert dynamic texts in your emails (the current month, an event name, etc…)
insert user information in your emails (a custom field, a personal information, etc…)
automatically insert content built in other extensions (products, events, articles, etc…)
execute a script when a specific action is performed in AcyMailing (when a new user subscribes, when a user is imported, etc…)
Creating my custom add-on
Joomla WordPress
First create the main folder for your add-on. It must be in lowercase with only letters: administrator/components/com_acym/dynamics/exampleaddon /
Inside this folder, create the file plugin.php like this one:
Copy <? php
use AcyMailing \ Libraries \ acymPlugin ;
class plgAcymExampleaddon extends acymPlugin
{
}
The class name MUST always be "plgAcym " followed by the folder name of your add-on, with a capital letter at the beginning.
First create the main folder for your WordPress plugin, for example wp-content/plugins/custom-add-on-for-acymailing /
In this folder, create the file custom-add-on-for-acymailing.php with the following content:
Copy <? php
/*
* Plugin Name: Custom add-on for AcyMailing
* Description: Insert dynamic texts inside sent emails
* Version: 1.0
* Requires Plugins: acymailing
*/
use AcyMailing \ Classes \ PluginClass ;
class myCustomAddonForAcyMailing
{
const INTEGRATION_PLUGIN_NAME = 'plgAcymExampleaddon' ;
private string $integrationName;
public function __construct ()
{
register_deactivation_hook ( __FILE__ , [ $this , 'disable' ] ) ;
register_uninstall_hook ( __FILE__ , [ $this , 'uninstall' ] ) ;
add_action ( 'acym_load_installed_integrations' , [ $this , 'register' ] , 10 , 1 ) ;
$this -> integrationName = strtolower ( substr ( self:: INTEGRATION_PLUGIN_NAME , 7 )) ;
}
public function disable () : void
{
if ( ! $this -> loadAcyMailingLibrary () ) {
return ;
}
$pluginClass = new PluginClass ();
$pluginClass -> disable ( $this -> integrationName ) ;
}
public function uninstall () : void
{
if ( ! $this -> loadAcyMailingLibrary () ) {
return ;
}
$pluginClass = new PluginClass ();
$pluginClass -> deleteByFolderName ( $this -> integrationName ) ;
}
public function register ( array & $integrations) : void
{
$integrations[] = [
'path' => __DIR__ ,
'className' => self:: INTEGRATION_PLUGIN_NAME ,
];
}
private function loadAcyMailingLibrary () : bool
{
$ds = DIRECTORY_SEPARATOR ;
$vendorFolder = dirname ( __DIR__ ) . $ds . 'acymailing' . $ds . 'vendor' ;
$helperFile = dirname ( __DIR__ ) . $ds . 'acymailing' . $ds . 'back' . $ds . 'helpers' . $ds . 'helper.php' ;
return file_exists ( $vendorFolder ) && include_once $helperFile;
}
}
new myCustomAddonForAcyMailing ();
You will need to modify:
your plugin name on line 3, that will be shown on your plugins listing
lines 11 and 64 to name the class however you like (make it something unique to avoid conflicts)
line 13 where the value MUST start with "plgAcym" and be followed by a capital letter then lowercase letters.
⚠️ Remember this value as it will be used as the class name of our add-on ⚠️
Create the file plugin.php in the same folder:
Copy <? php
use AcyMailing \ Libraries \ acymPlugin ;
class plgAcymExampleaddon extends acymPlugin
{
}
Notice that the class name MUST be the same you set in the previous file on line 13
Adding features to your custom add-on
Once your custom add-on's base files are created, you can add methods in the plugin.php file to customise AcyMailing features.
Execute custom script on specific AcyMailing actions Insert a dynamic text in an email for Joomla Insert a custom block in an email for Joomla Insert a dynamic text in an email for WordPress Insert a custom block in an email for WordPress Last updated 3 months ago