Custom Plugin Creation Question

Discussion in 'Customization & add-ons' started by lifestream, Aug 14, 2011.

  1. lifestream

    lifestream New Member

    Joined:
    Aug 3, 2011
    Messages:
    3
    So i've been following the API on creating a custom plugin with amember pretty easy, i've got a grasp on the callback actions and started writing code to fit... I ran into a bit of a snag (sorta) that I was able to bypass but I am curious how/what/why this occurs?

    There is an error that is causing the plugin to exit prematurely. It errors:
    "Error. Please configure 'plugin_template' plugin at aMember CP -> Setup -> plugin_template" this even shows up in a session dump.

    I can bypass this by commenting out sections (below) of this 'check' function and everything runs as expected. what exactly is it looking for? I don't have any config variables, so no setup just SQL queries. Am I ok bypassing this (seemingly)?

    It may be something I missed, I combed the documentation but its sparing in that department and not much here in the forum either. Hope this may help someone else too.

    Basically what is this function?

    Code:
    function check_setup_plugin_template(){
        global $plugin_config, $config, $db;
        
        $this_config = $plugin_config['protect']['plugin_template'];
        $nuke_db = $this_config['db'];
        if (!$nuke_db) {
            $error = "Error. Please configure 'plugin_template' plugin at aMember CP -> Setup -> plugin_template";
            if (!$_SESSION['check_setup_plugin_template_error']) $db->log_error ($error);
            $_SESSION['check_setup_plugin_template_error'] = $error;
            return $error;
        }
        return '';
    } 
    
    

    I can simply take this section out:

    Code:
     if (!$nuke_db) {
            $error = "Error. Please configure 'plugin_template' plugin at aMember CP -> Setup -> plugin_template";
            if (!$_SESSION['check_setup_plugin_template_error']) $db->log_error ($error);
            $_SESSION['check_setup_plugin_template_error'] = $error;
            return $error;
        }
    
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Would need to know a bit more on what your plugin is doing.

    * is it a protection or payment plugin?
    * does it have any UI (configuration panel, etc)
  3. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You can bypass this code (as you did already) if you on't have any configuration values.
    This function check was plugin configured or not and disable it if plugin was not configured yet.
    But you don't need this step if plugin do not have any configuration settings.
  4. lifestream

    lifestream New Member

    Joined:
    Aug 3, 2011
    Messages:
    3
    BINGO.. much thanks!

Share This Page