Answers.Body: <p>Generally best practice is to look into the source code and see what happens in the function</p>
  
  <pre><code>/**
   * Manually activates a user account.  Only admins have access.
   *
   * @return null
   */
  public function actionActivateUser()
  {
      $this-&gt;requireAdmin();
      $this-&gt;requirePostRequest();
  
      $userId = craft()-&gt;request-&gt;getRequiredPost('userId');
      $user = craft()-&gt;users-&gt;getUserById($userId);
  
      if (!$user)
      {
          $this-&gt;_noUserExists($userId);
      }
  
      if (craft()-&gt;users-&gt;activateUser($user))
      {
          craft()-&gt;userSession-&gt;setNotice(Craft::t('Successfully activated the user.'));
      }
      else
      {
          craft()-&gt;userSession-&gt;setError(Craft::t('There was a problem activating the user.'));
      }
  
      $this-&gt;redirectToPostedUrl();
  }
  </code></pre>
  
  <p>The important part is <code>$this-&gt;requireAdmin();</code>. Copy the function into a custom controller and remove that line and you are generally done. You can even hook into the CP template and include this the button on your own.</p>
  
  <h2>My Solution</h2>
  
  <p>I wrote a plugin that uses above method. It is accessed via a controller. I just changed the line that requires the user to be an admin. Then I just put a button somewhere in the CP that uses this controller action.</p>
  
  <pre><code>- $this-&gt;requireAdmin();
  
  + if (!craft()-&gt;userSession-&gt;getUser()-&gt;can('accessPlugin-MyNewPlugin')) {
  +    throw new HttpException(403, Craft::t("You don’t have the required permissions for this operation."));
  + }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-20T11:20:19.707Z
Answers.LastActivityDate: 2018-03-21T15:12:14.893Z
Answers.LastEditDate: 2018-03-21T15:12:14.893Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I am using CraftCMS 2.</p>
  
  <p>Beside the admins, I have 2 user groups: Employees and Editors. As admin I can activate pending Editor accounts by clicking on 'Activate account' in the corresponding user account. However, this button is not available for non-admins (Employees), even if the non-admin has all permissions of the user module. I understand that there is no way to make this button available for non-admins in control panel.</p>
  
  <p><strong>Question:</strong> Is there a way to make this action ('Activate account') available for Employees through a frontend form? Ultimately I want Employees to be able to activate pending Editors manually.</p>
  
  <p>Basically I want to do the same as <a href="https://craftcms.stackexchange.com/questions/23544/prevent-activation-email-on-creation-wait-for-admin-approval">Jeremy A</a> but with non-admins.</p>
  
Tags: <users><admin><activation>
Title: Manual user activation for non-admins
ThreadText: # Manual user activation for non-admins
  
  (Asked by: username_0 on 2018-03-20)
  
  I am using CraftCMS 2.
  
  Beside the admins, I have 2 user groups: Employees and Editors. As admin I can activate pending Editor accounts by clicking on 'Activate account' in the corresponding user account. However, this button is not available for non-admins (Employees), even if the non-admin has all permissions of the user module. I understand that there is no way to make this button available for non-admins in control panel.
  
  **Question:** Is there a way to make this action ('Activate account') available for Employees through a frontend form? Ultimately I want Employees to be able to activate pending Editors manually.
  
  Basically I want to do the same as [Jeremy A](https://craftcms.stackexchange.com/questions/23544/prevent-activation-email-on-creation-wait-for-admin-approval) but with non-admins.
  
  **Tags:** users, admin, activation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-03-20. Score: 2 | Accepted answer
  
  Generally best practice is to look into the source code and see what happens in the function
  
  ```
  /**
   * Manually activates a user account.  Only admins have access.
   *
   * @return null
   */
  public function actionActivateUser()
  {
      $this->requireAdmin();
      $this->requirePostRequest();
  
      $userId = craft()->request->getRequiredPost('userId');
      $user = craft()->users->getUserById($userId);
  
      if (!$user)
      {
          $this->_noUserExists($userId);
      }
  
      if (craft()->users->activateUser($user))
      {
          craft()->userSession->setNotice(Craft::t('Successfully activated the user.'));
      }
      else
      {
          craft()->userSession->setError(Craft::t('There was a problem activating the user.'));
      }
  
      $this->redirectToPostedUrl();
  }
  
  ```
  
  The important part is `$this->requireAdmin();`. Copy the function into a custom controller and remove that line and you are generally done. You can even hook into the CP template and include this the button on your own.
  
  ## My Solution
  
  I wrote a plugin that uses above method. It is accessed via a controller. I just changed the line that requires the user to be an admin. Then I just put a button somewhere in the CP that uses this controller action.
  
  ```
  - $this->requireAdmin();
  
  + if (!craft()->userSession->getUser()->can('accessPlugin-MyNewPlugin')) {
  +    throw new HttpException(403, Craft::t("You don’t have the required permissions for this operation."));
  + }
  
  ```
  
  
  ---
  
  