CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Run CiviMember Roles Sync after Membership Create/Edit
Pages: [1]

Author Topic: Run CiviMember Roles Sync after Membership Create/Edit  (Read 855 times)

copeco

  • Guest
Run CiviMember Roles Sync after Membership Create/Edit
April 23, 2009, 11:10:39 am
Hi all,

I came up with a simple way to run CiviMember Roles Sync after a membership is created or modified. Add the following code to civicrm/drupal/modules/civicrm_member_roles/civicrm_member_roles.module:

Code: [Select]
/**
 * Synchronize CiviCRM Member Roles when a Membership is created or modified
 * (only used when set to the login/logout method)
 */
function civicrm_member_roles_civicrm_post( $op, $objectName, $objectId, &$objectRef ) {
    if ( $objectName == 'Membership' && ( $op == 'create' || $op == 'edit' ) ) {
        civicrm_initialize( true );
        if (variable_get('civicrm_member_roles_sync_method', 0) == 0) {
            _civicrm_member_roles_sync();
        }
    }
}

I don't know if this will work in all scenarios, but it seems to be working for me!

  colin

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Run CiviMember Roles Sync after Membership Create/Edit

This forum was archived on 2017-11-26.