Making a plugin work

Discussion in 'Customization & add-ons' started by developer, Dec 11, 2008.

  1. developer

    developer New Member

    Joined:
    Dec 11, 2008
    Messages:
    4
    Hello.
    It appears that I don't understand fully how plugins work.
    I need some certain things to happen when a new subscription appears. Here's what I've done for that:
    1. Downloaded the plugins/protect/plugin_template folder, renamed plugin_template.inc.php to myplugin.inc.php, changed every plugin_template to myplugin in the code of myplugin.inc.php and config.inc.php; changed the folder name to myplugin.
    2. Written some php, just to test:
    Code:
    function myplugin_added($member_id, $product_id, $member){
        $this_config = $plugin_config['protect']['myplugin'];
        $email_msg = 'Hello Developer';
        $email_msg .= 'Product: '.$product_id;
        $email_msg .= 'Login: '.$member['login'];
        $email_msg .= 'Pass: '.$member['pass'];
        $email_msg .= 'First name: '.$member['name_f'];
        $email_msg .= 'Last name: '.$member['name_l'];
        $email_msg .= 'Email: '.$member['email'];
        foreach ($member['data'] as $memberkey => $membervalue) {
          $email_msg .= $memberkey.': '.$membervalue;
        }
        mail('mybox@mydomain.com', 'New subscription added', $email_msg);
    }
    
    3. Enabled myplugin at the aMember CP
    4. Added a user and added a subscription for that user at the aMember CP.
    As a result, no email in my box. What have I done wrong?
  2. developer

    developer New Member

    Joined:
    Dec 11, 2008
    Messages:
    4
    Update.
    Of course, I've missed this:
    2.5. Uploaded the myplugin folder back to the server.

    Now after I log into the admin area it sais "Error. Please configure 'myplugin' plugin at aMember CP -> Setup -> myplugin".

    What exactly needs to be done to configure it?
  3. developer

    developer New Member

    Joined:
    Dec 11, 2008
    Messages:
    4
    Hi again. The problem has been solved.
    Just commented the check_setup_myplugin() function.

Share This Page