Skip to content

Instantly share code, notes, and snippets.

@hypeJunction
Created October 16, 2013 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hypeJunction/7004080 to your computer and use it in GitHub Desktop.
Save hypeJunction/7004080 to your computer and use it in GitHub Desktop.
elgg_register_event_handler('init', 'system', 'custom_blog_notification_init');
function custom_blog_notifier_init() {
//Register an event listener to send email when blog is created
elgg_register_event_handler('publish', 'blog', 'custom_blog_notification_send');
}
/**
* Callback function to send a notification
*
* @param type $event Equals 'publish'
* @param type $type Equals 'blog'
* @param type $blog ElggEntity of subtype 'blog'
*/
function custom_blog_notification_send($event, $type, $blog) {
$subject = "New blog: $blog->title";
$body = $blog->description;
$user = $blog->getOwnerEntity();
$from = "$user->name <$user->email>";
$to = "someone@somewhere.com";
elgg_send_email($from, $to, $subject, $body);
return true;
}
@JETLI004
Copy link

Thanks so much for your update. I'v been trying to implement it on my site but it doesnt seem to be sending any email. I modified the "someone@somewhere.com" to my email. Is there something I'm getting wrong? The plugin just has start.php, and a manifest file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment