How to implement the enable and disable the plugin

Hugilore111

Member
Hi
How to add a plug-in to enable and disable?
You can see examples?
examples
4.jpg

how to check to enable or disable the plugin?
 

Andrej

Well-known member
You do not need to have a plugin disable/enable checkbox as it already exists by default.

Снимок экрана 2016-03-04 в 18.39.44.png
 

wang

Well-known member
Hi
How to add a plug-in to enable and disable?
You can see examples?
examples
View attachment 129808

how to check to enable or disable the plugin?

Are you talking about adding it to your add on? If so, when you create your option in the admin panel, you must set Edit Format to On/Off Check Box and Data Type to Boolean. And for Default Value, enter 1 if you want your option to run when excecuted, otherwise 0 or leave it blank. You must also remember that to be able to add options, the developer mode must be enabled.
 

Hugilore111

Member
Are you talking about adding it to your add on? If so, when you create your option in the admin panel, you must set Edit Format to On/Off Check Box and Data Type to Boolean. And for Default Value, enter 1 if you want your option to run when excecuted, otherwise 0 or leave it blank. You must also remember that to be able to add options, the developer mode must be enabled.
hello wang, thank you
it is not necessary to check, how to check here
examples
Code:
$visitor = XenForo_Visitor::getInstance();
     
        if (!XenForo_Permission::hasPermission($visitor['permissions'], 'forum', 'permissionName'))
        {
            return $this->responseNoPermission();
        }
 

wang

Well-known member
hello wang, thank you
it is not necessary to check, how to check here
examples
Code:
$visitor = XenForo_Visitor::getInstance();
    
        if (!XenForo_Permission::hasPermission($visitor['permissions'], 'forum', 'permissionName'))
        {
            return $this->responseNoPermission();
        }

I am not sure I understand what you want to do sir. That code will check members of a group for a custom permission, and return the no access error message.
 

Hugilore111

Member
I am not sure I understand what you want to do sir. That code will check members of a group for a custom permission, and return the no access error message.
sorry
I need to check whether or not the plugin is activated in the admin panel
 

wang

Well-known member
sorry
I need to check whether or not the plugin is activated in the admin panel

Try this code. Replace AddonName with the actual name of the add on that you want to check if it is active or not.

PHP:
if (XenForo_Application::isRegistered('addOns'))
{
       $addOns = XenForo_Application::get('addOns');
       if (!isset($addOns['AddonName']))
       {
             return $this->responseNoPermission();
       }
}
 

Cyb3r

Well-known member
I think this is what you are looking for:
Rich (BB code):
$addonIsActive = XenForo_Application::get('options')->myOptionTitle;

if($addonIsActive)
{
    // The add-on is active
}
else
{
    // The add-on is disabled
}

Don't forget to change myOptionTitle to your option name.
 
Top