1

Drush v3 had a --user flag (--user=1), however, this seems to be removed since v4, according to the website. How can I run Drush 5 as logged in as user 1?

7

See drush topic core-global-options; you will see that the --user flag is still supported.

Of course, you do not really 'log in' to your Drupal site with Drush. The usual convention is that Drush commands should call API-level functions, which are expected to operate independently of the current user. (Drupal does access checks before calling the API functions.) There are only a few instances, mostly in contrib, where setting the user is necessary.

  • I am having a problem now a few views API functions. For example, views_save_view() or $view->save() both return false when using Drush to execute scripts with those functions. However, running these in Drupal these run fine and everything works as expected. Are Views API functions different? The closest related issue I could find is here: drupal.org/node/1515616 comment #6. Some of my functions are embedded in cron as well. – blue928 Mar 3 '13 at 21:46
  • note, too, that running 'drush --user=1' results in the list of flag options; running 'drush --user=1 cron' or 'drush --user=1 script.php' still results in permission issues and immediately after 'drush status' still reports Anonymous. What am I doing wrong? – blue928 Mar 3 '13 at 21:51
  • Sorry, I can't answer your views api question off the top of my head. Perhaps if you posted a follow-up question specifically about calling views_save_view from Drush, someone who knows the answer will notice it. – greg_1_anderson Mar 3 '13 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.