authentication authorization – Where do I check whether logged in user in administrator, moderator or just authenticated user in Drupal 7?

I have 2 separate login pages for users and administrators userslogin and backendlogin.

I have created a new function in my custom theme as follows,

  function customtheme_theme() {

  $items = array(); 

  $items('user_login') = array(

    'render element' => 'form',

    'path' => drupal_get_path('theme', 'customtheme') . '/templates/user',

    'template' => 'user-login',


  $items('user_pass') = array(

    'render element' => 'form',

    'path' => drupal_get_path('theme', 'customtheme') . '/templates/user',

    'template' => 'user-pass',


  return $items;

and in /sites/all/themes/customtheme/templates/user I have created 2 files, user-login.tpl.php and user-pass.tpl.php.

Now in the user-login.tpl.php, I have put the following code,

<?php $login_form = drupal_get_form("user_login"); ?>

<?php print $messages; ?>

<input autocomplete="off" type="text" 
value="<?php echo $login_form('name')('#value'); ?>" 
id="<?php echo $login_form('name')('#id'); ?>" 
name="<?php echo $login_form('name')('#name'); ?>" 
placeholder="Enter your username" required="" 
oninvalid="this.setCustomValidity('Username id is required')" 

// password field..
// actions ..

So, I used the same setup for the admin login as well.

Created a new template at /sites/all/themes/customtheme/templates/page/page--backend.tpl.php

So in that page, I just called the user_loin form as below,

$elements = drupal_get_form("user_login"); 

$form = drupal_render($elements);   
echo ($form);

Now, both pages are working fine, But I need to show some message saying you are not allowed here if normal users logged in through backend form.

Am not able to figure out at which place/file/path I need to check for the user role and display the message(push to $mesages).

8 – Salesforce Connection – Drupal Answers

I am currently getting an error when trying to connect Drupal 8 with Salesforce. This will be the first time I am hooking into Salesforce from Drupal and I am not entirely sure what I am doing wrong. I am using the Salesforce Suite Module.

I get the following errors while creating a new authentication provider? (Not on a local environment so Salesforce can see the URL.)

Notice: Undefined property: Drupalsalesforce_jwtPluginSalesforceAuthProviderSalesforceJWTPlugin::$credentials in DrupalsalesforceSalesforceAuthProviderPluginBase->getCredentials() (line 194 of modules/contrib/salesforce/src/SalesforceAuthProviderPluginBase.php).

Warning: openssl_sign(): supplied key param cannot be coerced into a private key in FirebaseJWTJWT::sign() (line 209 of /home/client-name/vendor/firebase/php-jwt/src/JWT.php).

OpenSSL unable to sign data

Does anyone know where I could start looking or can provide insight into what these errors mean? I have been stuck on this a few days and I can’t seem to find anything helpful yet in my research.

The undefined property makes me think that I may be missing a dependency; however, this is a complete guess.

Thank you in advance.

How to retrieve cookie – Drupal Answers

In D8 Project, Cookie save p-nid1, p-nid2, p-nid3 (1, 2, 3 is node id). Cookie save with Drupal.visitor.p-nid1, Drupal.visitor.p-nid2, Drupal.visitor.p-nid3. But when get cookie

$nid = $node->id();
$cookieName = 'p-nid'.$nid;
$getCookieVal = Drupal::request()->cookies->get('Drupal_visitor_'.$cookieName);

Cookie not retrieve.
When doing clear chache the cookie retrieve.
I also disable module Internal Page Cache.
My question how to retrieve cookie without clear Cache for Anonymous.

Drupal 7 Views: Taxonomy exposed fields options should be visible even when there is no result

DRUPAL 7 – I have a multi exposed filters for a view. All are taxonomy reference fields. Screenshot – Image 1 below.

ISSUE: For filtering content based on some exposed filters options, for which there is no result, the exposed filters fields also become empty. When there is no result found screenshot is as below IMAGE-2.

EXPECTED BEHAVIOUR: The exposed filters options must be visible even where there is no result found.

IMAGE 1 - Normal without and exposed filter selected

enter image description here.

IMAGE 2 BELOW with selected exposed filters options with no result found.

enter image description here

commerce – Add to cart button not displaying inside custom text in drupal 8 views

I created a product display view in drupal8 to display the product.
For this, I added some fields like product price, title, and " add to cart" form.
When I call all the fields inside custom text fields, the add to cart button is not displaying on the page. To display the " add to cart" button, I am using

{{ variations_target_id }}

from replacement patterns.

PHP Segfault error when running Drupal 7 to 8 migration using drush

I ran drush migrate-upgrade on D8 fresh installed site and it generated the migrations (D7 to D8).
After that I tried to run users migration(after running roles and fields migration), I got an error with PHP Segfault.

(username@hostname drupal8)$ drush mim upgrade_d7_user
1410/34583 (=>————————–) 4%/usr/local/zend/bin/php: line 4: 6040 Segmentation fault $ZCE_PREFIX/php/active/bin/php -c $ZCE_PREFIX/php/active/etc/php.ini “$@”

I tried running the drush command with debug and verbose but got nothing useful.

enter image description here

installing – Cant install Drupal 9.0.2 with php 7.3

i wanna install Drupal 9.0.2 . I use Apache2 and PHP 7.3.2.
Im getting this Error on my website:

Your PHP installation is too old. Drupal requires at least PHP 7.3.0. See the system requirements page for more information.

php -v
PHP (cli) (built: Jul 9 2020 16:34:09) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache, Copyright (c) 1999-2018, by Zend Technologies

Thanks in advance.