• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

email members on new post

HenrikHansen

Well-known member
#6
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
 
#7
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
#8
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.
 
#9
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
#11
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)