Add a trusted member to the blog, can write comment without verification from a moderator.

@param Blog $blog
@param User $user

@return Member
172319
private function addTrustedMember(Blog $blog, User $user)
    {
        $member = new Member();
        $member->setBlog($blog);
        $member->setUser($user);
        $member->setTrusted(true);

        $this->om->persist($member);
        $this->om->flush();

        return $member;
    }
60376
public function update(BlogRequest $request, Blog $blog)
    {
        try {
            $attributes = $request->all();

            $blog->update($attributes);
            return $this->response->message(trans('messages.success.updated', ['Module' => trans('blog::blog.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('blog/blog/' . $blog->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('blog/blog/' . $blog->getRouteKey()))
                ->redirect();
        }

    }
379227
public function attachMember(User $user,
        /** @noinspection PhpUnusedParameterInspection */
                                   MemberTag $memberTag,
                                   $memberId)
    {
        return $user->selected_context->id === $memberId;
    }
1152236
protected function addLogSuccess(UserInterface $user)
    {
        $this->userManager->updateUser($user);

        $authLog = $this->createAuthLog();
        $authLog->setSuccess(true);
        $authLog->setUser($user);
        $authLog->setUsername($user->getUsername());

        $this->em->persist($authLog);
        $this->em->flush();
    }
27973
public static function start($title, User $user)
    {
        $discussion = new static;

        $discussion->title = $title;
        $discussion->created_at = Carbon::now();
        $discussion->user_id = $user->id;

        $discussion->setRelation('user', $user);

        $discussion->raise(new Started($discussion));

        return $discussion;
    }
1296413
public function addUser(UserInterface $user)
    {
        $this->users->add($user);

        if ($user->hasRole($this) === false)
            $user->addRole($this);

        return $this;
    }
1217500
public function createUser(User $user)
    {
        $query = $this->handler->createInsertQuery();
        $query
            ->insertInto($this->handler->quoteTable('ezuser'))
            ->set(
                $this->handler->quoteColumn('contentobject_id'),
                $query->bindValue($user->id, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('login'),
                $query->bindValue($user->login)
            )->set(
                $this->handler->quoteColumn('email'),
                $query->bindValue($user->email)
            )->set(
                $this->handler->quoteColumn('password_hash'),
                $query->bindValue($user->passwordHash)
            )->set(
                $this->handler->quoteColumn('password_hash_type'),
                $query->bindValue($user->hashAlgorithm, null, \PDO::PARAM_INT)
            );
        $query->prepare()->execute();

        $query = $this->handler->createInsertQuery();
        $query
            ->insertInto($this->handler->quoteTable('ezuser_setting'))
            ->set(
                $this->handler->quoteColumn('user_id'),
                $query->bindValue($user->id, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('is_enabled'),
                $query->bindValue($user->isEnabled, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('max_login'),
                $query->bindValue($user->maxLogin, null, \PDO::PARAM_INT)
            );
        $query->prepare()->execute();
    }
188256
protected function sendReactivationEmail(User $user)
    {
        $forum = Podium::getInstance()->podiumConfig->get('name');
        $email = Content::fill(Content::EMAIL_REACTIVATION);
        if ($email !== false) {
            $link = Url::to(['account/activate', 'token' => $user->activation_token], true);
            return Email::queue(
                $user->email,
                str_replace('{forum}', $forum, $email->topic),
                str_replace('{forum}', $forum, str_replace('{link}',
                    Html::a($link, $link), $email->content)),
                !empty($user->id) ? $user->id : null
            );
        }
        return false;
    }
1182513
public function createPostAction(Request $request, Blog $blog, User $user)
    {
        if ($this->checkPermission('EDIT', $blog->getResourceNode())
            || $this->checkPermission('POST', $blog->getResourceNode())) {
            $data = json_decode($request->getContent(), true);
            $post = $this->postManager->createPost($blog, $this->postSerializer->deserialize($data), $user);
        } else {
            throw new AccessDeniedException();
        }

        return new JsonResponse($this->postSerializer->serialize($post));
    }
324847
public function update(UserPolicy $user, Category $category)
    {
        if ($user->canDo('blog.category.edit') && $user->isAdmin()) {
            return true;
        }

        return $category->user_id == user_id() && $category->user_type == user_type();
    }
1007562
public function setupUser($user)
    {
        $question = new Question($this->db);
        $post     = new Post($this->db);
        $comment  = new Comment($this->db);
        $vote     = new Vote($this->db);

        // Basic setup for user
        $user->img        = $this->getGravatar($user->name);

        // Get all posts/votes user made
        $sqlAccept = "user = ? AND type = ? AND accepted = ?";
        $user->acceptedAnswers = count($post->getAllPosts($sqlAccept, [$user->name, "answer", "yes"]));
        $user->questions       = $question->getQuestions("user = ?", $user->name);
        $user->comments        = $comment->getComments("user = ?", $user->name);
        $user->posts           = $post->getAllPosts("user = ? AND type = ?", [$user->name, "answer"]);
        $user->votes           = $vote->getVote("user = ?", [$user->name]);


        // Amount of posts
        $user->postAmount = count($user->questions) + count($user->posts) + count($user->comments);

        // Algorithm for reputation points
        $user->reputation = $this->getReputation($user);

        // Get all the questions connected to answers
        $user->answeredQuestions = array_map(function ($answer) {
            $question = new Question($this->db);
            return $question->getQuestion($answer->questionId);
        }, $user->posts);

        return $user;
    }
701028
public function removeUser(User $user)
    {
        if ($this->users->contains($user)) {
            $this->users->removeElement($user);
        }

        return $this;
    }
881656
public function inviteUser(User $user)
    {
        return $this->client->apiCall('channels.invite', [
            'channel' => $this->getId(),
            'user' => $user->getId(),
        ])->then(function () use ($user) {
            $this->data['members'][] = $user->getId();
        });
    }
360785
public function create(User $user, $username, $password)
    {
        $this->authenticationService->create($user, $username, $password);
    }
83154
public function addUsersToNewBlogCron($blogId)
    {
        set_time_limit(60*60*60);

        global $wpdb;
        $users = $wpdb->get_results("SELECT ID FROM $wpdb->users");

        foreach ($users as $user) {
            $this->addDefaultRole($user->ID, $blogId);
        }
    }
1280643
public function addUser($user)
    {
        if (!$this->getUsers()->contains($user))
        {
            $this->getUsers()->add($user);
            $user->addGroup($this);
        }

        return $this;
    }
113435
public function createResetEmailToken(User $user, $email)
    {
        return $this->create($user, self::TYPE_EMAIL_RESET, new \DateTime('+1 day'), $email);
    }