I want to customize the "Edit Contact" form depending on roles. What's the best way to do it?
- create different templates. It's possible to distinguish inside a .tpl the user role?
- create a Drupal view
- ....
Thank's a lot
CiviCRM Stack Exchange is a question and answer site for administrators and users of the CiviCRM Constituent Relationship Management software. It only takes a minute to sign up.
Sign up to join this communityI want to customize the "Edit Contact" form depending on roles. What's the best way to do it?
Thank's a lot
You say you want to change 'Edit Contact' - but if you mean, you want a way for a logged in user to be able to be directed 'somewhere' to update their details, then here is one non-coding solution suitable for just a couple of different roles that i hope others can improve on. (The more I wrote this out the more convoluted it seemed
Ingredients: - one webform using webform_civicrm module per role - one View with displays set for each role
Recipe: Set the webforms up so cid1 is the logged in user, and provide the fields you want depending on the role for each webform. With the view make a block per role or use some php sauce so that the link that it provides varies per role. Stack the block(s) to show on /user perhaps. Set the link in the block to send the user to the webform that is relevant to their role.
Try using webform_civicrm!
make different webforms exposing different contact fields
you can do that for multiple contacts (i.e. make it into a batch update screen!)
After some research and test I think to take the solution to work on the template. Something like this:
{php}
global $user;
$roles_array = $user->roles;
if (array_key_exists(4,$roles_array)) {
$this->assign('customtemplate', True);
}
{/php}
{if $customtemplate}
....
But I dony'know if it will lower levels of security,