am_event hourly not working?

Discussion in 'Customization & add-ons' started by acetolyne, May 2, 2016.

  1. acetolyne

    acetolyne New Member

    Joined:
    Apr 21, 2016
    Messages:
    3
    Hello I have been working with Amember v 4 and now am trying to get the am_event hourly event to trigger but it seems to not be available in v4? Perhaps I am doing something wrong this is what I have
    In the site.php file i have added

    Am_Di::getInstance()->hook->add(Am_Event::HOURLY, 'checkOld');
    function checkOld(Am_Event $event){
    $file = ("test.log");
    $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
    fileputcontents($file, $today);
    }

    When I trigger my function in other ways it works just fine so the problem is with the hook and I cant seem to figure it out. Please inform if this hook is available in v4 since the documents show it should be. Thx for any help I appreciate your time.
  2. jenolan

    jenolan aMember Coder

    Joined:
    Nov 3, 2006
    Messages:
    510
    caesar likes this.
  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Yes, such event exits. It is required to set cron job so it work.
  4. acetolyne

    acetolyne New Member

    Joined:
    Apr 21, 2016
    Messages:
    3
    Ok do I need to set a cron job to the cron.php file for the hook to work? seems strange that you need to set a cron job to hourly and then the hook to hourly as well or do I not understand? Thx for your guidance I would really like to use the hook so its easier to implement and I have access to the database resources
  5. jenolan

    jenolan aMember Coder

    Joined:
    Nov 3, 2006
    Messages:
    510
    The hook is in response to processing, something is needed to make that happen reliably. The CRON job is simply a mechanism that allows for processing stuff that needs to happen automatically.
    caesar likes this.

Share This Page