1. 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

Discussion in 'XenForo Development Discussions' started by Hugilore111, Mar 4, 2016.

  1. Hugilore111

    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?
     
  2. Andrej

    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
     
  3. Hugilore111

    Hugilore111 Member

    check the code necessary
     
  4. wang

    wang Well-Known 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.
     
    Hugilore111 likes this.
  5. Hugilore111

    Hugilore111 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();
            }
     
  6. wang

    wang Well-Known 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.
     
  7. Hugilore111

    Hugilore111 Member

    sorry
    I need to check whether or not the plugin is activated in the admin panel
     
  8. wang

    wang Well-Known Member

    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();
           }
    }
     
    Hugilore111 likes this.
  9. Cyb3r

    Cyb3r Well-Known Member

    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.
     
    Hugilore111 likes this.

Share This Page