You are here

function simple_fb_connect_login_disabled_by_role in Simple FB Connect 7.2

Checks if the user has one of the "FB login disabled" roles.

Parameters

$drupal_user: Drupal user object.

Return value

bool True if login is disabled for one of this user's role. False if login is not disabled for this user's roles.

1 call to simple_fb_connect_login_disabled_by_role()
simple_fb_connect_login_user in ./simple_fb_connect.module
Logs the given user in.

File

./simple_fb_connect.module, line 885
Simple Facebook Login Module for Drupal Sites.

Code

function simple_fb_connect_login_disabled_by_role($drupal_user) {

  // Get module settings.
  $roles = variable_get('simple_fb_connect_disabled_roles', array());

  // Loop through all roles the user has.
  foreach ($drupal_user->roles as $role) {

    // Check if FB login is disabled for this role. Disabled roles have value > 0.
    if (array_key_exists($role, $roles) && !empty($roles[$role])) {
      watchdog('simple_fb_connect', 'FB login for user %user prevented. FB login for role %role is disabled in module settings.', array(
        '%user' => $drupal_user->name,
        '%role' => $role,
      ), WATCHDOG_WARNING);
      return TRUE;
    }
  }

  // If we didn't return TRUE already, FB login is not disabled for any of the user's roles.
  return FALSE;
}