We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14089
    • 56 Posts
    actually, i noticed one little issue. if a manager user creates a post, it returns a parse error. a simple if...then statements fixed it. hope this is help for other people.

    // Handle event
    $e = &$modx->Event;
    switch ($e->name) {
    case "OnDocPublished":
    //Get document info
    global $modx;
    $page_id = $modx->getPageInfo($docid);
    $content_table = $modx->getFullTableName("site_content");
    
    $data = $modx->db->getValue('SELECT createdby FROM '.$content_table.' WHERE id='.$page_id['id']);
    
    if ($data < 0)
    $table = $modx->getFullTableName("web_user_attributes");
    else
    $table = $modx->getFullTableName("user_attributes");
    
    $author = abs($data);
    
    $address = $modx->db->getValue('SELECT email FROM '.$table.' WHERE internalKey='.$author);
    
    $full_name = $modx->db->getValue('SELECT fullname FROM '.$table.' WHERE internalKey='.$author);
    
    $Name = "Indieophile"; //senders name
    $email = "[email protected]"; //senders e-mail adress
    $recipient = $address; //recipient
    $mail_body = $full_name.", your post, ".$page_id['pagetitle']. ", has been published. See it at http://www.indieophile.com/".$page_id['alias']; //mail body
    $subject = "your indieophile post has been published"; //subject
    $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
    
    mail($recipient, $subject, $mail_body, $header); //mail command
      break;
    
    default: "";
    
      return;
    }
      for all things independent, check out http://www.indieophile.com