如何在 drupal 的单独 php 页面中添加挂钩?
How to add hook in seperate php page in drupal?
我已经通过 curl 将我的核心 php 站点的表单值提交到 drupal 站点(http://xxyz.com/drupal_hook_register.php) link。在此页面中,我试图将电子邮件、密码直接插入到 drupal 数据库中。请帮我解决这个问题
// define static var
define('DRUPAL_ROOT', getcwd());
// include bootstrap
include_once('./includes/bootstrap.inc');
// initialize stuff
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
给你!
if($_POST) {
//Bootstraping Drupal
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$account = new stdClass();
$account->name = $_REQUEST['username'];
$account->mail = $_REQUEST['mail'];
$account->init = $_REQUEST['mail'];
$account->pass = user_password($_REQUEST['pass']); // you could use a random characters here too
$account->status = 1;
user_save(Null, $account);
if ($account->uid) {
drupal_set_message('Created new user with id %uid', array('%uid' => $account->uid));
echo 'success';
}
}
试试这个,因为它可以帮助你!
我已经通过 curl 将我的核心 php 站点的表单值提交到 drupal 站点(http://xxyz.com/drupal_hook_register.php) link。在此页面中,我试图将电子邮件、密码直接插入到 drupal 数据库中。请帮我解决这个问题
// define static var
define('DRUPAL_ROOT', getcwd());
// include bootstrap
include_once('./includes/bootstrap.inc');
// initialize stuff
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
给你!
if($_POST) {
//Bootstraping Drupal
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$account = new stdClass();
$account->name = $_REQUEST['username'];
$account->mail = $_REQUEST['mail'];
$account->init = $_REQUEST['mail'];
$account->pass = user_password($_REQUEST['pass']); // you could use a random characters here too
$account->status = 1;
user_save(Null, $account);
if ($account->uid) {
drupal_set_message('Created new user with id %uid', array('%uid' => $account->uid));
echo 'success';
}
}
试试这个,因为它可以帮助你!