Difference between revisions of "How to add welcome ticket in helpdesk when user signup"

From aMember Pro Documentation
Jump to: navigation, search
Line 2: Line 2:
 
<source>
 
<source>
 
<?php  
 
<?php  
        Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT, 'onUserAfterInsert');
+
Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT, 'onUserAfterInsert');
        function onUserAfterInsert(Am_Event $event){
+
function onUserAfterInsert(Am_Event $event){
            $user = $event->getUser();
+
    $user = $event->getUser();
            $di = Am_Di::getInstance();
+
    $di = Am_Di::getInstance();
            $ticket = $di->helpdeskTicketRecord;
+
            $ticket->user_id = $user->user_id;
+
            $ticket->status = HelpdeskTicket::STATUS_AWAITING_USER_RESPONSE;
+
  
            ///// TICKET SUBJECT
+
    $ticket = $di->helpdeskTicketRecord;
            $ticket->subject = 'Welcome user '.$user->name_f.' '.$user->name_l;
+
    $ticket->user_id = $user->user_id;
 +
    $ticket->status = HelpdeskTicket::STATUS_AWAITING_USER_RESPONSE;
  
 +
    // TICKET SUBJECT
 +
    $ticket->subject = 'Welcome user '.$user->name_f.' '.$user->name_l;
 +
    $ticket->insert();
 +
   
 +
    $message = $di->helpdeskMessageRecord;
 +
    $message->admin_id = 1; // ADMIN ID
  
            $ticket->insert();
+
    // TICKET BODY
            $message = $di->helpdeskMessageRecord;
+
    $message->content =  'Welcome to helpdesk. Simple content';
 
+
    $message->ticket_id = $ticket->ticket_id;
            $message->admin_id = 1; //// ADMIN ID
+
    $message->insert();
 
+
}
            ///// TICKET BODY
+
            $message->content =  'Welcome to helpdesk. Simple content';
+
 
+
 
+
 
+
            $message->ticket_id = $ticket->ticket_id;
+
            $message->insert();
+
           
+
        }
+
 
+
?>
+
 
</source>
 
</source>

Revision as of 03:49, 9 August 2013

Add this code to site.php file:

<?php 
Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT, 'onUserAfterInsert');
function onUserAfterInsert(Am_Event $event){
    $user = $event->getUser();
    $di = Am_Di::getInstance();
 
    $ticket = $di->helpdeskTicketRecord;
    $ticket->user_id = $user->user_id;
    $ticket->status = HelpdeskTicket::STATUS_AWAITING_USER_RESPONSE;
 
    // TICKET SUBJECT
    $ticket->subject = 'Welcome user '.$user->name_f.' '.$user->name_l;
    $ticket->insert();
 
    $message = $di->helpdeskMessageRecord;
    $message->admin_id = 1; // ADMIN ID
 
    // TICKET BODY
    $message->content =  'Welcome to helpdesk. Simple content';
    $message->ticket_id = $ticket->ticket_id;
    $message->insert();
}