0

I'm working on a Drupal 7 website in which there are several Profile types. As part of a task, I had to change the "Label Name" and the "Machine Name" of one of them: specifically Professional Courses was changed in Professional School.

Later on, I've realised that this substitution have broken the search in the Admin/People page. Precisely, if the Administrator, from the Admin/People page, searches the users with the Profile type just mentioned, the search shows no results.
I've discovered that the View managing this page (Admin/People), has kept the old Machine Name in the query, which means that role has been cut out.

I’ve tried to fix this error by changing the query using the following code inside a views_pre_execute function in a custom module I've developed:

$query = db_select('users', NULL);
$query->condition('users.uid', array('0'), 'NOT IN');
$query->fields('users', array('uid', 'name', 'mail', 'status', 'created', 'access'));
$query->addJoin('INNER', 'profile', NULL, 'users.uid = profile.uid AND (profile.type IN ( \'master_school\', \'employee\', \'summer_school\', \'professional_courses\', \'digital_friend\', \'phd_school\', \'professional_school\' ))');
$query->orderBy('users.access', 'DESC');
$query->range(0, 100);

$view->build_info['query'] = $query;

However, this code changes the query inside the View, but didn’t fix the problem.
How can I fix this bug? Should I go back to the old Machine Name?
Thanks!

P.S. I'm using Profile2 and Administration Views modules.

1
  • Why use a hook to modify a query? You can't enable the Views UI to modify the query directly?
    – Shawn Conn
    Apr 11, 2019 at 15:18

1 Answer 1

0

I think this is a bug in Profile2 module.
I recreated your issue on a test installation and the same results happened. After I inspected the database itself I found that the machine name was not changed in the table profile but correctly changed in profile_type table.
What you could try is to manually change the machine name in the profile table and see what happens then.
Also, it might be helpful to post your issue in Profile2 issue tracker, maybe they can fix this for other users.

Good luck.

1
  • Thank you for the answer. I will write an issue in the Profile2 issue tracker. I will keep you posted.
    – DamianFox
    Apr 17, 2019 at 13:21

Your Answer

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

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