#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!!!

#StackBounty: #8 #users #forms Custom user login in Facebook Auth modules

Bounty: 50

I try to run Facebook Login on my Drupal 8 site. I run it by Social API module and with Simple FB Connect, but both module generate user name from first and last name on Facebook. My user will not be happy with using real name, but I don’t want to give them options to change username whenever they want.

For code examples I use Simple FB Connect, but the same logic is in Social API modules.

User go to path user/simple-fb-connect and is redirected by Drupalsimple_fb_connectControllerSimpleFbConnectController->redirectToFb(), and when he is back, go to user/simple-fb-connect/return which is handle by Drupalsimple_fb_connectControllerSimpleFbConnectController->returnFromFb().

It checks permissions, get data from FB and then if email not exist in DB, registers user:

    // If there was no existing user, try to create a new user.
    $fbid = $fb_profile->getField('id');
    $fb_profile_pic = $this->fbManager->getFbProfilePic();
    if ($drupal_user = $this->userManager->createUser($fb_profile->getField('name'), $email, $fbid, $fb_profile_pic)) {

The main question is: How I can replace $fb_profile->getField('name') with custom, provided by user string ? I think about:

  1. Replace simple link on login with form contains textfield and submit button, which send POST/GET data to user/simple-fb-connect. There store it Session, and use on returnFromFb() function to create user.

But I can’t always show an additional field (eg. on homepage), and I don’t know if user want to register or just login. It kills idea, just click, and get account.

  1. After back from FB, show users one-time form, which they can’t skip, and access page, before they fill it, like post-login registration in normal FB integrations, on which they can fill additional data, but only once per account.

But there I have no idea how to even start. Maybe I can replace function returnFromFb() code creating new user with register form, and after submit create user. Or leave module code in peace and base it on events from the module. But how I can lock page for user who don’t fill this and secure it to be fill just one time (maybe boolean field on user entity?).

  1. The simplest way, just leave it as it is, use display name and hide login, but I don’t want to store user names and last names in database.

Thanks for help!

PS. I tried to ask the creators, but it looks like the modules work like they should work.

Get this bounty!!!