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 CiviMember (Moderator: Deepak Srivastava) »
  • Drupal Membership Site (please help)
Pages: 1 2 [3]

Author Topic: Drupal Membership Site (please help)  (Read 19686 times)

posco

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 8
Re: Drupal Membership Site (please help)
January 27, 2008, 05:48:32 pm
A friend of mine attended a CiviCRM developer conference and told me that CiviMember to Drupal Role synchronization could be accomplished with CiviCRM 2.0 natively. I'm assuming by your post that this isn't true. I would be more than happy to port my module in that case.

Right now I've only tested my code with CiviCRM v1.9 and Drupal 5.6 on a non-multisite configuration. I would like the code to be tested a little and to get some feedback before I begin porting anything. I will install the CiviCRM 2.0 alpha and begin planning the port though.

Right now I'm just waiting for my Drupal CVS account application to be processed.

Laryn

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 4
    • CEDC
  • CiviCRM version: 4.6.x
  • CMS version: Drupal 7
Re: Drupal Membership Site (please help)
January 28, 2008, 02:11:22 pm
This is great news! Looking forward to the module, which will be a real time saver.
CEDC...social justice by design

*Get support on the new CiviCRM help site. /laryn

posco

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 8
Re: Drupal Membership Site (please help)
January 29, 2008, 10:33:46 am
As promised here is a link to the published module:

http://drupal.org/project/civimember_roles

Hope everyone finds it useful. Any feedback would be greatly appreciated! Use the project page for that, though.

farmrchrys

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 2
    • Spokane Moves to Amend the Constitution (under development)
  • CiviCRM version: CiviCRM 4.4.6
  • CMS version: Drupal 7.31
  • MySQL version: MySQL 5.5.37
  • PHP version: PHP 5.3.28
Re: Drupal Membership Site (please help)
February 01, 2008, 09:09:56 pm
A module that would assign (or un-assign) Drupal users to certain Drupal roles depending on CiviCRM membership status can't be that hard, really, can it? And it would be so useful! Like Gordon's project civicrm_role it could be a cron job, simply periodically comparing the membership status (1, 2, 3 or 4), the cid and the uid. Since the Drupal roles table (rid) has one line for each users role (ie one line for user 6 to have role 3, another line for user 6 to have role 11) it would just be a matter of adding and removing rows of the roles table for that rid that indicates membership. Would be easier if there was just one Drupal role that indicated if a user was a member in good standing or not, but probably more useful if different membership types corresponded to different Drupal roles. Would be nice, if it's possible, for the cron job to run upon changes to the membership table or when a membership is added or renewed, so that updating of the Drupal role happens with as quick a turn-around as possible. Integrating it with Gordon's CiviCRM group/role module would make it quite a powerhouse.<br>In the mean time (now I'm new to this so don't laugh) I have a way to screen visitors to a page to tell if they're members or not. It won't let the page be written for non-members and redirects non-members to a "Sorry, this page is reserved for members" node. If you are a member, the page loads. Here it is. It goes in the body of a PHP formatted Drupal node:
Code: [Select]
<?

Global $user;
    if ($user->uid < 1){
    drupal_goto ($path='node/XXX');
// Your SORRY page
exit();
}
    elseif ($user->uid >= 1);{
    $userID = crm_uf_get_match_id($user->uid);
}
$query = "SELECT * FROM civicrm_membership WHERE contact_id = $userID";
 
$result2 = mysql_query ($query) or die ("Died");

$field2 = mysql_fetch_object($result2);

if ( $field2->status_id == 1 ) {

// 1 is new member

print (What you want it to print);
}
elseif ( $field2->status_id == 2 ) {

// 2 is current member

print (What you want it to print);
}

elseif ( $field2->status_id == 3 ) {

// 3 is grace period member, 4 is lapsed member

print (What you want it to print);
}
else {
    drupal_goto ($path='node/XXX');
// Your SORRY page
exit();
}

?>
Works for me.

posco

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 8
Re: Drupal Membership Site (please help)
February 02, 2008, 09:20:40 am
farmrchrys: To answer the first part of your post, my module essentially does what you are describing (see my previous post in this thread for a link). It provides quite a bit of flexibility and it does use roles, so you can just control the content with roles (instead of with drupal_goto()). It also allows you to use custom status rules and to associate multiple membership types with multiple roles. It does use hook_cron() as one of the methods it uses to update roles.

I didn't know about the crm_uf_get_match_id() function. I like how you grab the contact id that way. Maybe I should spend more time reading up on CiviCRM's API. I also like how your code instantly determines the users status (doesn't have to wait for hook_user() or hook_cron()).

Pages: 1 2 [3]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Drupal Membership Site (please help)

This forum was archived on 2017-11-26.