currentUserField() and core User fields

Hello,

I was wondering if one of you can answer this question : why core user fields are not available for the currentUserField() formula ?

Is there a logical reason I am missing that explains this ?

Because, while digging in the code, we understand that one property was missing for core fields (calculation_visible) but it seems that other vardefs properties are involved.

For instance, we were looking on an easy way to set a field as readonly if you are not an admin. The admin field is a core user field. We are able to customize the sugarfield_is_admin.php file and include 

$dictionary['User']['fields']['is_admin']['calculation_visible']=true;
But another property is missing for this field : $def['studio']['related'].
Because is_admin is a important field, we don't want to play with the studio.related property that we currently don't understand. Is someone aware about this vardefs property ?
Many thanks for your help.
Fred

the code I am talking about : 
  • include/Expressions/Expression/Generic/CurrentUserFieldExpression.php
  • modules/ExpressionEngine/formulaHelper.php with cleanFields function used from getValidUserFields function
Parents
  • Hi  ,

    I haven't personally modified the vardefs of is_admin and cannot say for certain why it is not made available. To accomplish this use case in the past, here is what I did:

    1. Create a checkbox field in the Users module (e.g. administrator_check_c) with the following attributes:
      1. Calculated: $is_admin
      2. Make visible for calculations: checked
    2. In the read-only formula, I reference that new field:
      Fullscreen
      1
      2
      3
      4
      5
      not(
      currentUserField(
      $administrator_check_c
      )
      )
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Chris

Reply
  • Hi  ,

    I haven't personally modified the vardefs of is_admin and cannot say for certain why it is not made available. To accomplish this use case in the past, here is what I did:

    1. Create a checkbox field in the Users module (e.g. administrator_check_c) with the following attributes:
      1. Calculated: $is_admin
      2. Make visible for calculations: checked
    2. In the read-only formula, I reference that new field:
      Fullscreen
      1
      2
      3
      4
      5
      not(
      currentUserField(
      $administrator_check_c
      )
      )
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Chris

Children
No Data