Created
October 16, 2013 07:44
-
-
Save hypeJunction/7004080 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "[email protected]"; | |
elgg_send_email($from, $to, $subject, $body); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 "[email protected]" to my email. Is there something I'm getting wrong? The plugin just has start.php, and a manifest file.