Communities e-mail Notification

Good morning, everyone.
I'm building a little social network with Elgg and I'm just loving it. But I would like to pre-check the e-mail section to all users in the group notifications settings.
I need that, anytime someone join a community, all the new discussions or files should generate an e-mail to alert all members (and this are disabled previously, the members should enable manually).

If it works with the pluggin Notifications Subject, it would be perfect. Anyone has any idea? Thank you guys so much

  • I happened to have this in an existing plugin. You can create your own plugin from it:

    /**
     * Initialize the plugin
     */
    function my_plugin_init () {
        elgg_register_event_handler('join', 'group', 'my_plugin_enable_notifications_for_new_group_member');
    }

    /**
     * Enable group notifications by default when user joins a group
     *
     * @param string $event  'join'
     * @param string $type   'group'
     * @param array  $params Array containing ElggUser and ElggGroup
     */
    function my_plugin_enable_notifications_for_new_group_member ($event, $type, $params) {
        $group = $params['group'];
        $user = $params['user'];

        if (!$group instanceof ElggGroup) {
            return;
        }

        if (!$user instanceof ElggUser) {
            return;
        }

        // Enable <method> as a notification method
        add_entity_relationship($user->guid, 'notify<method>', $group->guid);
    }

    Just replace the <method> part with the name of the notification method that you want to use. So in this case you would replace it with "email", so the relationship name becomes "notifyemail".

  • Got it. What about the start.php? It gets blank?

    Thank you

  • The manifest.xml is this code you have posted, isn't it? And do you have start.php code for this plugin? I'm sorry for bothering you but it's the first time I use Elgg and I have never lerned php. Thanks for your attention.

  • The code I posted goes to start.php.

    Here you can find a simple tutorial to help you get started with plugin development: http://learn.elgg.org/en/1.9/tutorials/hello_world.html

  • I've tried to use the start.php with the code you gave me and manifest.xml I used:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
            <name>Example Manifest</name>
            <author>Elgg</author>
            <version>1.0</version>
            <description>This is a simple example of a manifest file. In this example, there are not screenshots, dependencies, or additional information about the plugin.</description>
    
            <requires>
                    <type>elgg_release</type>
                    <version>1.9</version>
            </requires>
    </plugin_manifest>

    It's not working at all :( I'll give up this, a little too difficult to a newbie as like me. But thanks a lot for your patience 

  • Isn't there any "already-built" plugin?

  • I'm not aware of one, but yes, there might already be an existing plugin somewhere.

  • Hello, I am still looking for a plug-in like this, and no success. I am a newbie too.