Answers.Body: <p>The CiviCRM WordPress Member Sync plugin provides basic sync functionality and does not necessarily cover all possible use cases. What I would do in your case is use the <code>civi_wp_member_sync_add_role</code> hook to capture which user is being assigned which role. You can then remove the "Membership pending" role and make sure they only have the "Membership granted" role.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-25T12:20:38.483Z
Answers.LastActivityDate: 2016-10-25T12:20:38.483Z
Answers.UserDisplayName: Christian Wach
Body: <p>Christian Wach's excellent set of Wordpress plugins make that CMS viable for member's only sites - wouldn't work otherwise!</p>
  
  <p>Here's the query. Using the "Roles" option as the synchronization option, a Wordpress user with the Wordpress user role being e.g. "Membership pending" signs up for a CiviCRM membership and via the plugin gets assigned to the Wordpress user role "Membership granted".</p>
  
  <p>However, the Wordpress user now has two roles: "Membership pending" and "Membership granted".</p>
  
  <p>The $64.000 question then is:</p>
  
  <ul>
  <li>Is this by default, i.e. CiviCRM WordPress Member Sync does not switch Wordpress roles, but rather adds them, or</li>
  <li>I do have the <a href="https://de.wordpress.org/plugins/members/" rel="nofollow">Member's plugin</a> installed, with the multiple roles option not checked (although it had been in use previously), and I've now screwed up any forcing of only one user role per user until the end of time? </li>
  </ul>
  
  <p>If latter condition is in fact false - any ideas of how to make (the plugin?) not add a role but in fact switch it?</p>
  
  <p>Cheers!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-23T18:24:42.870Z
Comments.Text: Is "Membership pending" the default role?
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-24T11:10:43.670Z
Comments.Text: Yes - that's what the newly registered Wordpress user gets. BTW: I've implemented a sort of work-around by Setting up a CiviCRM Membership type that goes by the name "Pending acceptance", costs nothing and is for a lifetime. At the same time there now is a Membership status rule (OCD'ed "Pending acceptance") that has its start event set to "member since" and its end event set to "member since" -1 day adjustment (and is all the way at the top of the list, before new). That way the backoffice gives the newbie Membership type "Pending acceptance", which immediately expires, triggering your ->
Comments.UserDisplayName: Abteilung Gerontopsychiatrie
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-24T11:15:46.217Z
Comments.Text: plugin to change the Wordpress user roles to "Membership granted". Now the newbie gets permission to view restricted Wordpress pages (by the Members plugin) to continue on with payment. Sounds complicated!? But is necessary because German law (and our bylaws)requires the board to approve membership (of a "Verein") - before somebody pays their dues, making it difficult to not have them be part of the party... If the plugin could "change" roles instead of adding them, then... Cheers
Comments.UserDisplayName: Abteilung Gerontopsychiatrie
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-24T12:20:26.447Z
Comments.Text: The plugin removes the default role when a membership is updated: https://github.com/christianwach/civicrm-wp-member-sync/blob/master/civi-wp-ms-members.php#L435 so if they have that, then the new role should replace it. There's a conundrum when multiple memberships exist - should the plugin add roles or replace them? Or keep track of a "role stack"? I would say that you have given the best description of why you should be using capabilities rather than roles!
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-24T14:26:06.497Z
Comments.Text: Well at least it was good for that ;) On the other hand: Wouldn't capabilities amount to a dichotomization - view the page when member, don't view if not? In my case I've got three levels: Anonymous, Membership pending (i.e. the registration process with details on B'day, Organization, etc.) I want to keep away from the public eye and Membership accepted with payment and private pages PLUS no longer be able to read "Membership pending" pages (just in case somebody gets lost and by chance lands there, screwing up the registration process).
Comments.UserDisplayName: Abteilung Gerontopsychiatrie
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-24T14:49:28.523Z
Comments.Text: Not sure I understand. Each status equates to an abstract capability - it's up to you how to code *what* that capability entitles the user to do.
Comments.UserDisplayName: Christian Wach
Tags: <wordpress>
Title: CiviCRM WordPress Member Sync - adding a new role or changing an existing one
ThreadText: # CiviCRM WordPress Member Sync - adding a new role or changing an existing one
  
  (Asked by: username_0 on 2016-10-23)
  
  username_1's excellent set of Wordpress plugins make that CMS viable for member's only sites - wouldn't work otherwise!
  
  Here's the query. Using the "Roles" option as the synchronization option, a Wordpress user with the Wordpress user role being e.g. "Membership pending" signs up for a CiviCRM membership and via the plugin gets assigned to the Wordpress user role "Membership granted".
  
  However, the Wordpress user now has two roles: "Membership pending" and "Membership granted".
  
  The $64.000 question then is:
  
  * Is this by default, i.e. CiviCRM WordPress Member Sync does not switch Wordpress roles, but rather adds them, or
  * I do have the [Member's plugin](https://de.wordpress.org/plugins/members/) installed, with the multiple roles option not checked (although it had been in use previously), and I've now screwed up any forcing of only one user role per user until the end of time?
  
  If latter condition is in fact false - any ideas of how to make (the plugin?) not add a role but in fact switch it?
  
  Cheers!
  
  **Tags:** wordpress
  
  > **Comments:**
  > **username_1**: Is "Membership pending" the default role?  
  > **username_0**: Yes - that's what the newly registered Wordpress user gets. BTW: I've implemented a sort of work-around by Setting up a CiviCRM Membership type that goes by the name "Pending acceptance", costs nothing and is for a lifetime. At the same time there now is a Membership status rule (OCD'ed "Pending acceptance") that has its start event set to "member since" and its end event set to "member since" -1 day adjustment (and is all the way at the top of the list, before new). That way the backoffice gives the newbie Membership type "Pending acceptance", which immediately expires, triggering your ->  
  > **username_0**: plugin to change the Wordpress user roles to "Membership granted". Now the newbie gets permission to view restricted Wordpress pages (by the Members plugin) to continue on with payment. Sounds complicated!? But is necessary because German law (and our bylaws)requires the board to approve membership (of a "Verein") - before somebody pays their dues, making it difficult to not have them be part of the party... If the plugin could "change" roles instead of adding them, then... Cheers  
  > **username_1**: The plugin removes the default role when a membership is updated: https://github.com/username_1/civicrm-wp-member-sync/blob/master/civi-wp-ms-members.php#L435 so if they have that, then the new role should replace it. There's a conundrum when multiple memberships exist - should the plugin add roles or replace them? Or keep track of a "role stack"? I would say that you have given the best description of why you should be using capabilities rather than roles!  
  > **username_0**: Well at least it was good for that ;) On the other hand: Wouldn't capabilities amount to a dichotomization - view the page when member, don't view if not? In my case I've got three levels: Anonymous, Membership pending (i.e. the registration process with details on B'day, Organization, etc.) I want to keep away from the public eye and Membership accepted with payment and private pages PLUS no longer be able to read "Membership pending" pages (just in case somebody gets lost and by chance lands there, screwing up the registration process).  
  > **username_1**: Not sure I understand. Each status equates to an abstract capability - it's up to you how to code *what* that capability entitles the user to do.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-10-25. Score: 2
  
  The CiviCRM WordPress Member Sync plugin provides basic sync functionality and does not necessarily cover all possible use cases. What I would do in your case is use the `civi_wp_member_sync_add_role` hook to capture which user is being assigned which role. You can then remove the "Membership pending" role and make sure they only have the "Membership granted" role.
  
  
  ---
  
  