0

I have webform where volunteers signup for newsletter. They land on group called "Volunteer".

Our volunteer co-ordinator users are in a drupal role called "Coordinator"

What I want is, those "Coordinator" users would ONLY be able to access the contacts from the group "Volunteer". I can easily achieve this by using related permission extension https://github.com/eileenmcnaughton/nz.co.fuzion.relatedpermissions .

But I am failing to automate the process of creating a relationship between the volunteers and Drupal users. If any new Drupal user is added to the same role, the relationship would automatically be created. I am open to alternatives. Any suggestion would be greatly appreciated. Thanks

3
  • "I am failing to automate the process of creating a relationship between the volunteers and Drupal users" is not conceptually correct. You would want to be creating a Relatinships between Contact X and Contact Y and would not be using Groups. You could connect Contact X to Contact G (being eg Volunteers) and then connect Contact G to your Coordinators. that is how that extension could help. Otherwise you could look at Rules.
    – petednz - fuzion
    Dec 18, 2020 at 3:06
  • but to be honest, your first two paragraphs sound like an obvious case for a normal civi ACL.
    – petednz - fuzion
    Dec 18, 2020 at 3:07
  • @petednz-fuzion thanks. My end goal is to limit the coordinator’s access to see only volunteer contacts. And I need that process to be automated. How can I do that?
    – Tapash
    Dec 18, 2020 at 6:06

2 Answers 2

1

Perhaps a case for a normal civi ACL - perhaps using CiviRules to put your Volunteer Managers in to the ACL Group which then has access to see those in the Volunteer Group.

0

Use the Silent User Registration extension https://lab.civicrm.org/extensions/silentuserreg This will create the user in Drupal

Before you install the extension, replace the Createcmsuser.php file in CRM > Silentuserreg > CivirulesAction with the code below. This will create the UF Match that you are looking for to link it to the user in Civi

Follow the extension instructions to set it up. I would have your CiviRule trigger off When contact is added to group or something like that.

<?php

/**

  • Carls Notes
  • This file is to create a CRMUser and then a UFMatch record. File Location=secure/sites/all/files/civicrm/extensionsions/silentuserreg-master/CRM/Silentuserreg/Silentuserreg / /*
  • Class for CiviRules Create User Action
  • @author Jon Goldberg ([email protected])
  • @license AGPL-3.0 */ class CRM_Silentuserreg_CivirulesAction_Createcmsuser extends CRM_Civirules_Action {

/**

  • Method processAction to execute the action
  • @param CRM_Civirules_TriggerData_TriggerData $triggerData
  • @access public

/ public function processAction(CRM_Civirules_TriggerData_TriggerData $triggerData) { $cid = $triggerData->getContactId(); $userInfo = \Civi\Api4\Email::get() ->addSelect('id', 'email', 'contact.display_name', 'is_primary') ->addWhere('is_primary', '=', TRUE) ->addWhere('contact_id', '=', $cid) ->setCheckPermissions(FALSE) ->execute() ->first(); $userExists = (bool) count(\Civi\Api4\UFMatch::get() ->addWhere('contact_id', '=', $cid) ->setCheckPermissions(FALSE) ->execute()); if (!$userExists) { $userParams['cms_name'] = $userParams['nickname'] = $userInfo['contact.display_name']; $userParams['email'] = $userInfo['email']; $userParams['cms_pass'] = CRM_Silentuserreg_Util::randomPassword(); $nid=CRM_Core_BAO_CMSUser::create($userParams, 'email'); // create the UF Match record $ufmatch['uf_id'] = $nid; $ufmatch['contact_id'] = $cid; $ufmatch['uf_name'] = $userInfo['email']; CRM_Core_BAO_UFMatch::create($ufmatch); } } /*

  • Method to return the url for additional form processing for action
  • and return false if none is needed
  • @param int $ruleActionId
  • @return bool
  • @access public */ public function getExtraDataInputUrl($ruleActionId) { return FALSE; }

}

2
  • Thanks. But how this process would create relationships?
    – Tapash
    Dec 17, 2020 at 22:58
  • My bad. I misunderstood. I was thinking Create relationship between Drupal user and Civi Users
    – Iowa Boy
    Dec 17, 2020 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.