Answers.Body: <p>Yes, your <strong>Accepted</strong> field should be an <strong>Entries</strong> custom field.</p>
  
  <p>You can limit the field to only allow you to select entries from the <strong>Members Channel</strong>. e.g. you would only tick the 'Members' source (see image)</p>
  
  <p><a href="https://i.sstatic.net/qCSj0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qCSj0.png" alt="enter image description here"></a></p>
  
  <p>This would allow you to select (or remove) one or more Member entries, when publishing or editing an <strong>Activity</strong> entry.</p>
  
  <p>More info in the docs, here: <a href="https://craftcms.com/docs/entries-fields" rel="nofollow noreferrer">https://craftcms.com/docs/entries-fields</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-29T13:18:48.333Z
Answers.Text: I have already set up the Activities and Members as you described above, but I need a php method in my plugin to add Members to and remove Members from activities. Do you know how I would write this in php?
Answers.UserDisplayName: Rbijker.com
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-29T15:17:56.527Z
Answers.Text: Please give us more info... Could you describe the basis on which you would add/remove a Member from an Activity?
Answers.UserDisplayName: Matt P
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-29T15:47:50.593Z
Answers.Text: I want to add/remove the Member via an API entry point in my custom plugin. So the user makes a request to this entry point, and then I add/remove him from the activity.
Answers.UserDisplayName: Rbijker.com
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-29T13:10:03.437Z
Answers.LastActivityDate: 2016-03-29T13:10:03.437Z
Answers.UserDisplayName: Matt P
Answers.Body: <p>A relationship field expects an array of element IDs. So to remove a user, you'd just get all the current IDs and remove
  the one you want to delete.</p>
  
  <pre><code>// Get the current member IDs
  $members = $entry-&gt;accepted-&gt;ids();
  
  // Remove a member ID
  $key = array_search(52, $members); 
  if ($key !== false) {
      unset($members[$key]);
  }
  
  // Add a new member ID
  $members[] = 83;
  
  // Update the member IDs
  $entry-&gt;setContentFromPost(array(
      'accepted' =&gt; $members
  ));
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-29T21:49:21.717Z
Answers.LastActivityDate: 2016-03-29T21:49:21.717Z
Answers.UserDisplayName: carlcs
Body: <p>I have a channel called 'Activities' and a channel called 'Members'. 
  In 'Activities' I have a field called 'Accepted'. I want to be able to add and remove 'Members' to the field 'Accepted'.
  I want to do this in a plugin that I am building. Is there a method to add or delete a single 'Member' to the 'Accepted' field of an 'Activity'?
  Basically is should remove the relationship between the Activity and the Member, but it should not remove the Member itself.</p>
  
Tags: <plugin-development><relations><craft-pro>
Title: How to remove relationships between entries
ThreadText: # How to remove relationships between entries
  
  (Asked by: username_0 on 2016-03-29)
  
  I have a channel called 'Activities' and a channel called 'Members'.
  In 'Activities' I have a field called 'Accepted'. I want to be able to add and remove 'Members' to the field 'Accepted'.
  I want to do this in a plugin that I am building. Is there a method to add or delete a single 'Member' to the 'Accepted' field of an 'Activity'?
  Basically is should remove the relationship between the Activity and the Member, but it should not remove the Member itself.
  
  **Tags:** plugin-development, relations, craft-pro
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-03-29. Score: 4 | Accepted answer
  
  A relationship field expects an array of element IDs. So to remove a user, you'd just get all the current IDs and remove
  the one you want to delete.
  
  ```
  // Get the current member IDs
  $members = $entry->accepted->ids();
  
  // Remove a member ID
  $key = array_search(52, $members); 
  if ($key !== false) {
      unset($members[$key]);
  }
  
  // Add a new member ID
  $members[] = 83;
  
  // Update the member IDs
  $entry->setContentFromPost(array(
      'accepted' => $members
  ));
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2016-03-29. Score: 1
  
  Yes, your **Accepted** field should be an **Entries** custom field.
  
  You can limit the field to only allow you to select entries from the **Members Channel**. e.g. you would only tick the 'Members' source (see image)
  
  [![enter image description here](https://i.sstatic.net/qCSj0.png)](https://i.sstatic.net/qCSj0.png)
  
  This would allow you to select (or remove) one or more Member entries, when publishing or editing an **Activity** entry.
  
  More info in the docs, here: <https://craftcms.com/docs/entries-fields>
  
  > **Comments:**
  > **username_0**: I have already set up the Activities and Members as you described above, but I need a php method in my plugin to add Members to and remove Members from activities. Do you know how I would write this in php?  
  > **username_1**: Please give us more info... Could you describe the basis on which you would add/remove a Member from an Activity?  
  > **username_0**: I want to add/remove the Member via an API entry point in my custom plugin. So the user makes a request to this entry point, and then I add/remove him from the activity.  
  
  ---
  
  