Answers.Body: <p>Within the context of that event, you will have access to:</p>
  
  <pre><code>$event-&gt;params['user']
  </code></pre>
  
  <p>... which is:</p>
  
  <blockquote>
    <p><a href="http://buildwithcraft.com/docs/plugins/events-reference#users-onActivateUser" rel="nofollow">A UserModel instance representing the user that has just been activated.</a></p>
  </blockquote>
  
  <p>Once you've got your user model, you can do something like this:</p>
  
  <pre><code>$event-&gt;params['user']-&gt;isInGroup('artists')
  </code></pre>
  
  <hr>
  
  <p>On a separate note, I believe the correct syntax is:</p>
  
  <pre><code>craft()-&gt;on('users.activateUser' ...
  </code></pre>
  
  <p>You can ditch the "on" in <code>onActivateUser</code>. Check out the <a href="http://buildwithcraft.com/docs/plugins/hooks-and-events#listening-for-events" rel="nofollow">official example...</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T09:10:21.033Z
Answers.LastActivityDate: 2014-07-17T09:10:21.033Z
Answers.UserDisplayName: Lindsey D
Body: <p>I'm trying my first plug-in; it's to automatically create an entry in a section when a user belonging to a specific user group is activated. However I'm not that hot at PHP and I can't figure out how I would check that the user being activated belongs to a given user group. Here's my basic code from in the main plugin file's init() function:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function init() {
      craft()-&gt;on('users.onActivateUser', function(Event $event) {
          // check the user being activated belongs to the user group 'artist'
          // ???
  
          // now save an entry on their behalf
          $entry = new EntryModel();
          ...
  
          $success = craft()-&gt;entries-&gt;saveEntry($entry);
  
          if (!$success)
          {
              Craft::log('Couldn’t save the entry "'.$entry-&gt;title.'"', LogLevel::Error);
          }
      }
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-17T08:51:31.103Z
Comments.Text: I'm pretty sure I need to call isInGroup - but I don't understand what I'm calling that on, or how... $event->isInGroup('artists')?
Comments.UserDisplayName: Matt Wilcox
Tags: <plugin-development><events><usermodel>
Title: How do I access the properties of an object which triggered an event?
ThreadText: # How do I access the properties of an object which triggered an event?
  
  (Asked by: username_0 on 2014-07-17)
  
  I'm trying my first plug-in; it's to automatically create an entry in a section when a user belonging to a specific user group is activated. However I'm not that hot at PHP and I can't figure out how I would check that the user being activated belongs to a given user group. Here's my basic code from in the main plugin file's init() function:
  
  ```php
  public function init() {
      craft()->on('users.onActivateUser', function(Event $event) {
          // check the user being activated belongs to the user group 'artist'
          // ???
  
          // now save an entry on their behalf
          $entry = new EntryModel();
          ...
  
          $success = craft()->entries->saveEntry($entry);
  
          if (!$success)
          {
              Craft::log('Couldn’t save the entry "'.$entry->title.'"', LogLevel::Error);
          }
      }
  }
  
  ```
  
  **Tags:** plugin-development, events, usermodel
  
  > **Comments:**
  > **username_0**: I'm pretty sure I need to call isInGroup - but I don't understand what I'm calling that on, or how... $event->isInGroup('artists')?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-17. Score: 3 | Accepted answer
  
  Within the context of that event, you will have access to:
  
  ```
  $event->params['user']
  
  ```
  
  ... which is:
  
  > [A UserModel instance representing the user that has just been activated.](http://buildwithcraft.com/docs/plugins/events-reference#users-onActivateUser)
  
  Once you've got your user model, you can do something like this:
  
  ```
  $event->params['user']->isInGroup('artists')
  
  ```
  
  ---
  
  On a separate note, I believe the correct syntax is:
  
  ```
  craft()->on('users.activateUser' ...
  
  ```
  
  You can ditch the "on" in `onActivateUser`. Check out the [official example...](http://buildwithcraft.com/docs/plugins/hooks-and-events#listening-for-events)
  
  
  ---
  
  