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) »
  • access control - restrict a group of users from editing own record
Pages: [1]

Author Topic: access control - restrict a group of users from editing own record  (Read 4943 times)

aeszq

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 0
access control - restrict a group of users from editing own record
May 07, 2013, 10:40:22 pm
Hi,

Are there any ways that can restrict a group of users from editing own record? By default an authenticated user who have permission "access civicrm" can edit his/her own information on the contact/view page. I want to override this so they can only view the information.

Drupal 7 + Civicrm4.3.2

Cheers,
George

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: access control - restrict a group of users from editing own record
May 08, 2013, 07:32:58 am

You should be able to do this via a hook and implement permissioning in the buildForm hook for the contact edit page

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

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: access control - restrict a group of users from editing own record
May 08, 2013, 11:34:58 am
Also you could not give them "Access CiviCRM" permission and show them their contact dashboard instead.
Try asking your question on the new CiviCRM help site.

aeszq

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 0
Re: access control - restrict a group of users from editing own record
May 08, 2013, 09:48:43 pm
Hi,

Thanks for the help. I have managed to get the user's Drupal's Role in the hook_civicrm_buildForm(). But I'm not sure how to change the permission. Could you provide me a little more details on how to do it?

My idea is that
1. get the Role in the hook_civicrm_buildForm()
2. change the pemission to 'view self only' from 'edit self' if the role is "read-only"

Thanks,
George

roland

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
Re: access control - restrict a group of users from editing own record
May 17, 2013, 12:17:08 am
Hi G, not too sure if anyone has responded to you directly on this but when you find the answer please let me know. Lobo, is George on the right path here?

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: access control - restrict a group of users from editing own record
May 17, 2013, 06:40:37 am

implement the hook only for the edit form

if the user should not edit the form, set a message in the session

CRM_Core_Session::setStatus

and redirect back o the view page

ping us on irc if u need help

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • access control - restrict a group of users from editing own record

This forum was archived on 2017-11-26.