email members on new post

wcardinal

Member
is it possible to set it up so that a notification email is sent to all members if there is a new post in a forum?
 

HenrikHansen

Well-known member
Install the addon "Forum Watch", then go to options", make sure "Always Notify About New Reply" is disabled, so it is only new threads in forums, not new posts. Your members can decide if they want emails or just alerts for EACH forum
 

wcardinal

Member
yes I understand that a user can choose to click "watch forum". but how do set it so that ALL members are watching a forum automatically?
 

HenrikHansen

Well-known member
yes I understand that a user can choose to click "watch forum". but how do set it so that ALL members are watching a forum automatically?
I am quite sure (ie. 98% sure) that the xml file somewhere for that mod has a setting whether the email check box should automatically be ticked or not for all watched forums. If is that important for you, I would check and edit manually.
I do not think the mod automatically signs people up for emails.
 

wcardinal

Member
how do I modify this code to getUsers that are only in a certain group? or only users that are admins?

PHP:
class MonthlyEmails_Model_Email extends XenForo_Model
{
    public function sendMonthlyEmails()
    {
        $users = $this->getModelFromCache('XenForo_Model_User')->getUsers(array(
            'user_status' => 'valid',
            'receive_admin_email' => 1,
        ), array(
            'join' => XenForo_Model_User::FETCH_USER_FULL
        ));
 
        $viewParams = array(
            'options' => XenForo_Application::get('options'),
            'threads' => $this->_getRecentPublicThreads()
        );
 
        foreach ($users as $user)
        {
            $mail = XenForo_Mail::create('monthly_email', array_merge($viewParams, array('user' => $user)), $user['language_id']);
            $mail->enableAllLanguagePreCache();
            $mail->queue($user['email'], $user['username']);
        }
    }
 
    protected function _getRecentPublicThreads()
    {
        $nodeModel = $this->getModelFromCache('XenForo_Model_Node');
        $nodes = $nodeModel->getAllNodes(false, true);
        $nodePermissions = $nodeModel->getNodePermissionsForPermissionCombination(1);
        $nodeHandlers = $nodeModel->getNodeHandlersForNodeTypes(
            $nodeModel->getUniqueNodeTypeIdsFromNodeList($nodes)
        );
        $nodes = $nodeModel->getViewableNodesFromNodeList($nodes, $nodeHandlers, $nodePermissions);
        $nodes = $nodeModel->mergeExtraNodeDataIntoNodeList($nodes, $nodeHandlers);
        $nodes = $nodeModel->prepareNodesWithHandlers($nodes, $nodeHandlers);
 
        $postIds = array();
        foreach ($nodes as $node)
        {
            if (!empty($node['last_post_id']))
                $postIds[$node['last_post_id']] = $node['last_post_date'];
        }
        arsort($postIds);
        $postIds = array_slice(array_keys($postIds), 0, 3);
        $threads = $this->getModelFromCache('XenForo_Model_Post')->getPostsAndParentData($postIds);
 
        return $threads[1];
    }
 
}
 
R

ragtek

Guest
PHP:
$users = $this->getModelFromCache('XenForo_Model_User')->getUsers(array(
'user_status' => 'valid',
'receive_admin_email' => 1,
'secondary_group_ids' => array(1,2,3)
), array(
'join' => XenForo_Model_User::FETCH_USER_FULL
));






admin:

PHP:
$users = $this->getModelFromCache('XenForo_Model_User')->getUsers(array(
'user_status' => 'valid',
'receive_admin_email' => 1,
'is_admin' => true
), array(
'join' => XenForo_Model_User::FETCH_USER_FULL
));

(it's just out of my head, hadn't tested it)
 
Top