php Drupal Resetear usuario

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Drupal Resetear usuario相关的知识,希望对你有一定的参考价值。

<?php
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

if (pathinfo(__FILE__, PATHINFO_FILENAME) == 'admin-pass-reset') {
  die('Please change your file name to a random string to continue');
}

// Boot Drupal.
$autoloader = require __DIR__ . '/autoload.php';

$request = Request::createFromGlobals();
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod', FALSE);
$kernel->boot();

// Get password hasher service.
$password_hasher = $kernel->getContainer()->get('password');

// Hash password.
if (isset($_GET['pass']) && !empty($_GET['pass'])) {
 $newhash =  $password_hasher->hash($_GET['pass']);
}
else {
  die('Retry with ?pass=PASSWORD set in the URL');
}

// Update user password.
$updatepass = Drupal::database()->update('users_field_data')
  ->fields(array(
    'pass' => $newhash,
//  'name' => 'admin',
//	'mail' => 'yourmail@example.com'
  ))
  ->condition('uid', '1', '=')
  ->execute();

// Clean user 1 cache.
Drupal::cache('entity')->delete('values:user:1');

print "Done. Please delete this file as soon as possible";

以上是关于php Drupal Resetear usuario的主要内容,如果未能解决你的问题,请参考以下文章

php 在drupal 8中找到名字: - Drupal 8

php 在drupal 8中以编程方式创建词汇和术语: - Drupal

Drupal 6 视图 2:PHP 片段

Drupal,在自定义 php 页面上嵌入视图块/结果

PHP Drupal输出真正的PHP

增加 PHP 内存限制(Apache、Drupal6)