Hello,

Iam using field validation for validate "match against a field" in the user profile. This works fine for the administrator. But for "normal" user there is always the message witch is displayed when I do a wrong input. But the input is right. Can anyone help me please?

Best regards
Frank

Comments

g089h515r806’s picture

have you installed other access control modules?
Does normal user have permission to access the field which validate against?

fraweg’s picture

Hello,

thanks for your fast answer!
Yes I am using (for the profile) profile2 with profile2-privacy and (for the account) field permissions.
Every user has the right to edit an view his own fields. This issue happens in the account and also in the profile.

Thanks for any help!
Frank

Edit:
I have tested out all permissions on my site. This feature works only if I set this Node permission to the user:

Node

Bypass content access control
View, edit and delete all content regardless of permission restrictions. Warning: Give to trusted roles only; this permission has security implications.

But for the administrator this value must not be set to work.

Here is the code of my validation rule:

$rule = new stdClass();
$rule->disabled = FALSE; /* Edit this to true to make a default rule disabled initially */
$rule->api_version = 2;
$rule->rulename = 'Name given visible role';
$rule->name = 'name_given_visible_role';
$rule->field_name = 'field_your_name_by_role';
$rule->col = 'given';
$rule->entity_type = 'profile2';
$rule->bundle = 'profile';
$rule->validator = 'field_validation_match_field_validator';
$rule->settings = array(
  'entity_type' => 'user',
  'bundle' => 'user',
  'field_name' => 'field_name',
  'column' => 'Given',
  'reverse' => 0,
  'errors' => 0,
);
$rule->error_message = 'Please enter the same value for the given name as you did during your registration.';

Does anyone have the same issue or have an Idea to make it work?

fraweg’s picture

Hello g089h515r806,

do you have any Idea what I can do? I really need this feature.

Best regards
Frank

g089h515r806’s picture

1, one method is give normal user more permission
2, another method is copy the logic code of "match against a field" , change it to meet your requirment,you could change the code to let it bypass the permission check.

g089h515r806’s picture

Status: Active » Fixed

Fixed, Test it with latest Code.
I have added following code to bypass all access checkings:

$query->addMetaData('account', user_load(1));
fraweg’s picture

Thanks a lot !!!

Thats are really good news. I will test it the next days.

Best regards
Frank

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.