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) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • member type only event?
Pages: [1]

Author Topic: member type only event?  (Read 718 times)

Franco

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
member type only event?
October 25, 2013, 12:11:06 pm
Using verision 4.3.7 civicrm on drupal 6

I am wondering if there is a way to create membership only events on civicrm. which would be restricted by specific Member types.

I already tried using ACL to restrict the groups, but there's no way to automatically sync all member types to a specific group. (ACL's dont apply to Smart Groups)
Basically when someone pays to be a certain Membertype they can access Member only events. When Membertype expires, they no longer have access.

This seems to be a pretty basic reason to even have Paid Membership Registration.

Again, How can we have member only Event registrations?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: member type only event?
October 25, 2013, 01:26:52 pm

there is no built in support for this as yet. You'll need to implement this via hooks. Implement the civicrm_buildForm hook and if a member only event, validate that the user has a membership etc

This might be basic working for your org, but has not come up a lot (or any) on the forums so far. Please do share your code and implementation

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Franco

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: member type only event?
October 28, 2013, 10:06:29 am
This is my implementation as of now and I used the Public Event? checkbox in the event settings which is also used to include the event in promotional listings such as RSS feeds, iCal files or feeds, and event listing pages. This just checks if a user has the membership_type_id of 1 then they can access the page, otherwise it redirects them to the purchase membership page using JavaScript.

Code: [Select]
function HOOK_fixed_memberships_civicrm_alterContent(  &$content, $context, $tplName, &$object )
{

  //Check if this is an event Registation form
  if($tplName == 'CRM\Event\Form\Registration\Register.tpl' && $context == 'form'){
    //Check if is_public is set, if not show only to members
    if (!$object->_values['event']['is_public']){

      //Use Membership API
      $module_path = drupal_get_path('module', 'civicrm');
      require_once $module_path.'/../api/v2/Membership.php';

      //Get info about the current user
      $session =& CRM_Core_Session::singleton();
      $contact_id = $session->get( 'userID' );

      //Params to use to check if this user has a specific Membership Type
      $params = array( 'contact_id' => $contact_id );
      // Filter Active memberships
      $params['active_only'] = true;
      //Get the First membership type which should be Member
      $params['membership_type_id'] = '1';

      //Get the array of active memberships
      $membershipGet =& civicrm_membership_contact_get( $params );

      //If there are no memberships then redirect to purchase membership page
      if($membershipGet['record_count'] < 1){
         $content = '<p>ERROR: You must be an Member to access this page</p> <script> location.href = "/content/purchase-membership"; </script>';
      }
    }
  }
}

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: member type only event?
October 28, 2013, 10:32:09 am

might want to use api v3 since api v2 is deprecated and is no longer shipped from v4.4

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Franco

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: member type only event?
October 28, 2013, 11:33:08 am
Thanks i've updated it to use API v3.

Code: [Select]
function HOOK_memberships_civicrm_alterContent(  &$content, $context, $tplName, &$object )
{

  //Check if this is an event Registation form
  if($tplName == 'CRM\Event\Form\Registration\Register.tpl' && $context == 'form'){
    //Check if is_public is set from Public Event? main events option , if not show only to members
    if (!$object->_values['event']['is_public']){

      //Use Membership API
      $module_path = drupal_get_path('module', 'civicrm');
      require_once $module_path.'/../api/v3/Membership.php';

      //Get info about the current user
      $session =& CRM_Core_Session::singleton();
      $contact_id = $session->get( 'userID' );


      //Params to use to check if this user has a specific Membership Type
      $params = array(
        'version' => 3,
        'sequential' => 1,
        'contact_id' => $contact_id,
        'active_only' => true,
        'membership_type_id' => '1',
      );

      //Get the array of active memberships
      $membershipGet = civicrm_api('Membership', 'get', $params);

      //If there are no memberships then redirect to purchase membership page
      if($membershipGet['count'] < 1){
         $content = '<p>ERROR: You must be an Member to access this page</p> <script> location.href = "/content/purchase-membership"; </script>';
      }
    }
  }
}

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • member type only event?

This forum was archived on 2017-11-26.