• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to implement the enable and disable the plugin

wang

Well-known member
#4
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.
 
#5
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
#6
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.
 

wang

Well-known member
#8
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
#9
I think this is what you are looking for:
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.