Answers.Body: <pre><code>Craft::$app-&gt;elements-&gt;on(Elements::EVENT_BEFORE_SAVE_ELEMENT, function(ElementEvent $e) {
  
      // Make sure it's an entry.
      if ($event-&gt;element instanceof \craft\elements\Entry) {
          $entry = $event-&gt;element;
  
          // Check if it's in the section you care about
          if ($entry-&gt;sectionId == 1) {
              // Do your custom logic
          }
      }
  });
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-23T08:06:38.273Z
Answers.Text: thanks Brad - is there a list of events for future ref?
Answers.UserDisplayName: Steven Grant
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-26T03:36:07.140Z
Answers.Text: Not currently... easiest to search the Craft source for `const EVENT_` to see them all.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-22T22:48:20.353Z
Answers.LastActivityDate: 2020-04-22T22:48:20.353Z
Answers.UserDisplayName: Brad Bell
Body: <p>if that entry is in a particular section, then I want to do some task.</p>
  
  <p>I can't really find the event docs I need to do that. Everything I've come across has been for Craft 2.</p>
  
  <p>Any steps for a hint?</p>
  
Tags: <plugin-development><craft3><events>
Title: Do something on save of an entry
ThreadText: # Do something on save of an entry
  
  (Asked by: username_0 on 2020-04-22)
  
  if that entry is in a particular section, then I want to do some task.
  
  I can't really find the event docs I need to do that. Everything I've come across has been for Craft 2.
  
  Any steps for a hint?
  
  **Tags:** plugin-development, craft3, events
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-04-22. Score: 2 | Accepted answer
  
  ```
  Craft::$app->elements->on(Elements::EVENT_BEFORE_SAVE_ELEMENT, function(ElementEvent $e) {
  
      // Make sure it's an entry.
      if ($event->element instanceof \craft\elements\Entry) {
          $entry = $event->element;
  
          // Check if it's in the section you care about
          if ($entry->sectionId == 1) {
              // Do your custom logic
          }
      }
  });
  
  ```
  
  > **Comments:**
  > **username_0**: thanks username_1 - is there a list of events for future ref?  
  > **username_1**: Not currently... easiest to search the Craft source for `const EVENT_` to see them all.  
  
  ---
  
  