Программная авторизация Drupal

  1. <?php
  2. define('DRUPAL_ROOT', getcwd());
  3.  
  4. require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
  5. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  6.  
  7. $user = user_load(1);
  8.  
  9. if ($user) {
  10. $edit = (array)$user;
  11. list($major_version, ) = explode('.', VERSION);
  12. if ($major_version == '6') {
  13. user_authenticate_finalize($edit);
  14. }
  15. elseif ($major_version == '7') {
  16. user_login_finalize($edit);
  17. }
  18.  
  19. drupal_set_message("Don't forget to delete " . __FILE__, 'warning');
  20. drupal_goto();
  21. }
  22. else {
  23. echo '<h2>Error.</h2>';
  24. }
Russian
Категория: 
The code has been tested and works
Мультитег: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Target Image