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

Procedures to Normalize User Merging?

Discussion in 'XenForo Development Discussions' started by Jaxel, Aug 1, 2013.

  1. Jaxel

    Jaxel Well-Known Member

    Is there a procedure yet to normalize user merging with addons?
     
  2. Jaxel

    Jaxel Well-Known Member

    For now I am doing this... just want to know if there is a better way:
    Code:
    <?php
    
    class EWRmedio_Model_User extends XFCP_EWRmedio_Model_User
    {
        public function mergeUsers(array $target, array $source)
        {
            $response = parent::mergeUsers($target, $source);
           
            XenForo_Db::beginTransaction();
           
            $this->_getDb()->query("UPDATE EWRmedio_comments SET username = ? WHERE user_id = ?", array($target['username'], $source['user_id']));
            $this->_getDb()->query("UPDATE EWRmedio_comments SET user_id = ? WHERE user_id = ?", array($target['user_id'], $source['user_id']));
            $this->_getDb()->query("UPDATE EWRmedio_media SET username = ? WHERE user_id = ?", array($target['username'], $source['user_id']));
            $this->_getDb()->query("UPDATE EWRmedio_media SET user_id = ? WHERE user_id = ?", array($target['user_id'], $source['user_id']));
            $this->_getDb()->query("UPDATE EWRmedio_playlists SET user_id = ? WHERE user_id = ?", array($target['user_id'], $source['user_id']));
           
            $this->_getDb()->query("DELETE FROM EWRmedio_read WHERE user_id = ?", $source['user_id']);
            $this->_getDb()->query("DELETE FROM EWRmedio_users WHERE user_id = ?", $source['user_id']);
            $this->_getDb()->query("DELETE FROM EWRmedio_watch WHERE user_id = ?", $source['user_id']);
    
            XenForo_Db::commit();
           
            return $response;
        }
    }
    
     

Share This Page