2

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

4

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.

  • Thank's pete, I just installed the webform and had a fast look. But I'm afraid, in this direction, my need are too complex. In my form I need, custom fields (eg. new "preferred methods" to put near the default ones), button for address autocomplete, ajax call, .... I don't know if webform are enough powerful for that. – marcello May 10 '16 at 8:51
  • 1
    perhaps you should expand your question then to fully explain what it is that you need to achieve. but have you read the webform_civicrm documentation. It has amazing abilities with civicrm custom data etc. – petednz - fuzion May 10 '16 at 10:06
  • Mainly what I need is: 1) create a custom template where custom fields are near standard ones 2) put some default values in some custom & standard fields 3) validate (with DB calls) some fields before submit 4) put an address validate/autocomplete routine (Google). I had a look at the documentation and make sone quick tests, but I'm not sure webforms can solve all my needs – marcello May 10 '16 at 10:38
  • what do you mean by 'near standard ones'? – petednz - fuzion May 10 '16 at 18:51
  • eg. some custom "preferred methods" that in the form should be close to the standard ones – marcello May 11 '16 at 8:47
2

Try using webform_civicrm!

  1. make different webforms exposing different contact fields

  2. you can do that for multiple contacts (i.e. make it into a batch update screen!)

    1. set the webform permissions such that different roles can submit the different forms
0

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,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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