1. 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

Discussion in 'General XenForo Discussion and Feedback' started by wcardinal, Jul 31, 2012.

  1. wcardinal

    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?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    New thread in a forum? Or new thread in a post?

    There's the Watch Thread feature which already notifies people of new posts in a thread they're watching.

    There's also this add-on: http://xenforo.com/community/threads/bd-forum-watch.31112/

    Which will allow your users to watch a forum and therefore receive e-mails if new threads are posted.
     
  3. wcardinal

    wcardinal Member

    I want it to be ON by default - so that everyone gets notified unless they decide to turn it off
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    You want Watch Thread to be on by default?
     
  5. wcardinal

    wcardinal Member

    watch forum, not watch thread
     
  6. HenrikHansen

    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
     
  7. wcardinal

    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?
     
  8. HenrikHansen

    HenrikHansen Well-Known Member

    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. wcardinal

    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(falsetrue);
            
    $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), 03);
            
    $threads $this->getModelFromCache('XenForo_Model_Post')->getPostsAndParentData($postIds);
     
            return 
    $threads[1];
        }
     
    }
     
    fsierrac likes this.
  10. wcardinal

    wcardinal Member

    I am sure this is a simple question (above) can anyone help me out?
     
  11. ragtek

    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)
     

Share This Page