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 CiviContribute (Moderator: Donald Lobo) »
  • Contribution Page Access Control
Pages: [1]

Author Topic: Contribution Page Access Control  (Read 370 times)

edc1

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Contribution Page Access Control
August 29, 2012, 01:25:24 pm
Hi All,

is there any way of setting up access control on contribution pages? We have two contribution pages. One for individuals renewing their membership and another for families. Can you stop a user with a family membership getting access to the contribution page for an individual if the user changes the URL in their browser. We'd also like to prevent users from getting to the renewal contribution pages completely if their membership is current, i.e. hasn't yet expired. This doesn't seem to be possible with CiviCRM ACLs.

Em.

edc1

  • I’m new here
  • *
  • Posts: 28
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Contribution Page Access Control
August 30, 2012, 10:13:31 am
I've worked out a fairly simple way of doing this. In Drupal you can put something like this in hook_init().

global $user;

$roles = $user->roles;

foreach ($roles as $role) {
    if ($role == 'Full Member') {
        if (preg_match('/\/civicrm\/contribute\/transact\?reset=1&id=2/', $_SERVER['REQUEST_URI'])) {
       drupal_access_denied();
        }
    }
}

That's assuming you have your CiviCRM membership status synced with Drupal roles. If not I'm sure you can do something similar using:

civicrm_api("MembershipStatus","get"...

Em.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Contribution Page Access Control

This forum was archived on 2017-11-26.