#StackBounty: #views #users Changing a Profile type Machine Name broke the Admin/People search

Bounty: 50

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?

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

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.