Questions tagged [external-scripts]

Use it for question about calling Drupal functions or methods from an external PHP script.

Filter by
Sorted by
Tagged with
0 votes
0 answers
92 views

Temporary file issue when creating a file from an external script

I would like to create a file and write some data to it using a PHP CLI script. The script will bootstrap Drupal and then use either the file_system or file.repository services to perform the task. ...
H M's user avatar
  • 21
1 vote
0 answers
2k views

Programmatically add a node

Some years ago I made a Drupal 7 site. I want to remake the site with Drupal 9. In Drupal 7 I added nodes programmatically with this PHP code. define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT ...
Anna's user avatar
  • 11
-1 votes
1 answer
205 views

Query user_field_data in Drupal

I need to query the user_field_data table to see if a user exists. Through a query string, I pass to a php script that is on the server username and password in clear text. This script connects to the ...
falconenero's user avatar
1 vote
1 answer
1k views

"Fatal error: Call to a member function setFormClass()"

I am trying to load the node in an external script, and shows me the following error. Fatal error: Call to a member function setFormClass() in field_ui_entity_type_build() The code causing the error ...
Tanvir Ahmad's user avatar
1 vote
1 answer
371 views

Programmatically log in a user

I am trying to authenticate users as below. I don't get any error, but it doesn't log in users. autoLogin.php is located in the root folder. Visiting http://example.com/drupal8/autoLogin.php shows me ...
likeachamp's user avatar
0 votes
1 answer
544 views

How do I log in a user?

I want to log in Drupal 8 users from an external PHP file. I am trying the following code. use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; use Drupal\user\UserInterface; //$...
sourabh's user avatar
0 votes
0 answers
169 views

Add image using cURL

I'm migrating data from Zoho creator into Drupal 7. I wrote a PHP script to get all records and save them into nodes and that worked fine, but I need help to get the images and add them to the nodes ...
Rahif Abboud's user avatar
0 votes
0 answers
96 views

How do I use a core class from an external script? [duplicate]

I am trying to access a node programmatically and getting errors though using (AFAIK) the recommended way. My code (so far) is really simple. use Drupal\node\Entity\Node; $nid=1805; $node = Node::...
hank's user avatar
  • 37
0 votes
1 answer
46 views

Allow authorization via cookies

We are migrating from Drupal 7 to Drupal 8 and are currently at the last hurdle - relying on Drupal's session to authenticate for custom scripts. Previously we used to rely on drupal_bootstrap but now ...
kieran_delaney's user avatar
0 votes
2 answers
91 views

Is there a cli equivalent of the web ui with underspecification?

background I run drush cget markdown.settings and see: dependencies: module: - markdown parser: id: michelf/php-markdown-extra render_strategy: type: none settings: ...
jhnc's user avatar
  • 149
2 votes
1 answer
57 views

How can I check to see differences across my multisites?

Currently, we're using Acquia Content Hub to syndicate content across our sites with a spoke and wheel syndication architecture. We essentially use a single site (that content editors use to create/...
Daniel's user avatar
  • 59
1 vote
0 answers
285 views

Checking if user logged-in by external script, fails

With a script on an external webpage (same domain), I need to detect whether the user that's visiting the page is or not logged in. [EDIT] This occurs when the script is into a subfolder. If it's put ...
Tormy Van Cool's user avatar
0 votes
1 answer
323 views

How do I render the main navigation menu?

In Drupal 7, we were able to render the main navigation menu onto a page outside the main Drupal folders by including bootstrap.inc and displaying it with this code. $menuData = menu_tree_output(...
johnnyeng's user avatar
0 votes
1 answer
346 views

How can I bootstrap?

How can I bootstrap Drupal 8 from an external script? This an example script from the RabbitMQ Work Queues tutorial. require_once __DIR__ . '/vendor/autoload.php'; use PhpAmqpLib\Connection\...
johndevman's user avatar
0 votes
1 answer
54 views

Is it possible for 3rd Party Script to Create Users [closed]

Our company has many systems that require for users to have user names and passwords. We have been able to use SAML to cut down on the number of accounts we must manually create. With that said, we ...
Scott's user avatar
  • 273
0 votes
0 answers
229 views

Running a PHP script with Elysia CRON

I want to automatically run a PHP script every 3 hours or so. The script is pretty heavy. It pulls XML data from another website then encodes it into a JSON file to be imported by feeds. The ...
Webmastercolin's user avatar
1 vote
1 answer
244 views

How can I bootstrap a multi-site instance?

It's possible to bootstrap Drupal 8 and create a new node using answer # 174474. define('DRUPAL_DIR', '/usr/share/nginx/html'); use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\...
Ch4mb3rs's user avatar
2 votes
2 answers
734 views

Load node entity from external script with image URI

I'm attempting to grab a node from a node ID in an external php script. With Drupal 7 I used the bootstrap.inc but with Drupal 8 this are a bit different. I've called Drupal with: define('...
MysticQuack's user avatar
3 votes
1 answer
3k views

how to include external php file in drupal 8 [closed]

I want to merge two xlsx file and download merged file in drupal 8. So i used a PHPExcel library for doing so. But i am not able to include a PHPExcel.php file in custom controller for that. I used ...
user avatar
0 votes
1 answer
46 views

PHP filtered page is cached

With a few years of Drupal 6 and 7 experience, I've happily made my first Drupal 8 installation. In my previous installations of Drupal I've used custom made PHP code that does a lookup in a personal ...
Pål D's user avatar
  • 1
-1 votes
1 answer
426 views

How to insert PHP code into the Drupal 7 block with PHPFilter to enable a html form working?

<form action="run_pipeline.php" method="post"> Insert SRA identifier <input type="text" name="email"><br> <input type="submit" value="Run data processing pipeline"> </form&...
Flight747's user avatar
2 votes
1 answer
45 views

How to mass copy the title of each node to a taxonomy term?

I need to copy the title of nodes to its taxonomy term. I have the following content type Title - text Body - text Taxonomy term - (currently empty) I want to copy the "Title" ---> "Taxonomy term" ...
FOP-drupalist's user avatar
2 votes
1 answer
52 views

how to tell which book node is the root node programatically [closed]

If I have some nodes that are of type book, how can I go through them in a php script and tell which is the root? thanks
Diana's user avatar
  • 3,274
0 votes
3 answers
385 views

How do I access the Drupal class from a standalone PHP file?

How do I use the \Drupal class in an standalone PHP file?
Neelam Chaudhary's user avatar
2 votes
0 answers
45 views

Sharing data in the same database, being able to edit data

I am looking for a way for Drupal to be able to access and modify data in an external table in the same database. Both Drupal and the script need access to the same data. Duplicating/Migrating is ...
Scott M. Stolz's user avatar
2 votes
1 answer
1k views

What is the best (secure) way to run PHP code on a Drupal 8 system?

I am pretty new with Drupal. I have installed Drupal 8.17 on my webserver and now I am configuring it. It runs on Ubuntu 16.04 with Apache 2.4 and PHP-7.0, the DBMS is PostgreSQL 9.5. I would like ...
jlandercy's user avatar
  • 123
-2 votes
1 answer
63 views

Creation of a Content Type to Meet Required Use Case

How do I achieve the following Use Case? Use Case Example Widgets, Inc. offers franchising opportunities. They have 3 different franchising levels (bronze, silver and gold). Widgets, Inc. needs to ...
Mike Stratton's user avatar
0 votes
1 answer
47 views

Running Drupal API Scripts offline

I want to run some maintenance scripts against a Drupal 7 system. These scripts will call the Drupal API to use things like EntityFieldQuery, node->save and so on. I could create a module called ...
Monkeybrain's user avatar
2 votes
1 answer
2k views

How do I check the current user session?

In Drupal 7, I was able to use bootstrap.inc in an external PHP script, which was a custom set of pages that simply bootstrapped Drupal to check the user was logged in Drupal. The following code is a ...
tremor's user avatar
  • 133
1 vote
1 answer
264 views

Is it possible to have an external script run index.php that bootstraps Drupal?

It seems like such a simple question, and I apologize for my Drupal ignorance, but I am unable to get our Drupal contractors to accomplish what seems to be a simple request. I need the below script ...
GDP's user avatar
  • 115
0 votes
1 answer
952 views

How do I use the login for an external application?

Long ago I built a php based application for room reservations which basically ran on its own – outside the website's CMS. It was part of what I would now call a custom made intranet – or "custom-app"....
tillinberlin's user avatar
  • 1,110
2 votes
2 answers
1k views

How to store a single array value into a session variable? [closed]

I have Array ( [0] => cid [1] => TN201501HP ) Now I want to store "TN201501HP" into some session variable. How to store this value to a session variable?
Rajender Rajan's user avatar
0 votes
2 answers
126 views

Is a MySQL statement from an external script possible?

I'm working with a PM on a Drupal project, and we're having little success finding a developer to answer (what we believe to be) a simple question. I'm afraid I have no Drupal experience to speak of. ...
GDP's user avatar
  • 115
15 votes
5 answers
8k views

Bootstrap from external script

I am trying to create Drupal entity instances from an external script that is not part of Drupal or a Drupal module. For Drupal 7 there was drupal_bootstrap to load the required Drupal dependencies. ...
sleidig's user avatar
  • 543
1 vote
1 answer
166 views

Access to other custom php pages

I am new to Drupal, so please bare with me. I have a Drupal site that is working fine. Now what I want to do is allow access to folder which contains some custom php script. I tried to put the ...
Mystro's user avatar
  • 23
-2 votes
1 answer
168 views

Is this way safe to bootstrap Drupal from an external PHP script? [duplicate]

I want to bootstrap Drupal from an external PHP file located in Drupal's root directory. The following code will do the job. error_reporting(E_ALL); ini_set("display_errors", 1); define('DRUPAL_ROOT',...
Shad81's user avatar
  • 74
0 votes
1 answer
38 views

Multilanguage Website

I'm trying to run some script from Pinterest, to validate my site. What's happenning is I need to write in Pinterest the url of my site, but my site redirects always like this : "XXX.com/es". How can ...
DarkteK's user avatar
  • 427
0 votes
0 answers
29 views

Webform mail sending is successful but message says otherwise [duplicate]

I have this webform for contact. The site uses phpmailer 7.x-3.x-dev and library 5.2.9. When the webform is submitted, I get the error : Unable to send e-mail. Contact the site administrator if ...
Kartagis's user avatar
  • 612
0 votes
0 answers
51 views

Prevent image uploads with embedded code

I have a site which allows anonymous users to create a node with an image (the site allows people to submit images with quote memes so that the authenticity of the quote can be verified, quotefail.com)...
Kenny Wyland's user avatar
  • 3,058
-1 votes
2 answers
4k views

How do you get DRUPAL_ROOT when using it in a separate php file?

It has been covered many many times on several sites, explaining how to define DRUPAL_ROOT and bootstrap the page (whatever that actually means). However no one has ever said how to use it in a ...
James's user avatar
  • 29
0 votes
1 answer
1k views

How to include an external PHP script?

I have PHP file and I need to include that PHP file in static page. Where is best place to store that PHP file so I can include it in a static page.
bhanushalimahesh3's user avatar
0 votes
1 answer
132 views

Placing a drupal menu on an external site

I have a drupal install (latest 7.x version at the time of writing). It is in the root directory of my domain. In a non drupal sub-directory, called 'member' so at /member, I have 3rd party script ...
njwrigley's user avatar
  • 188
1 vote
2 answers
663 views

Getting "Fatal error: Class not found" by bootstrapping external script and executing user_save function

I have a problem i've struggled with for a long time, and it's starting to really piss me off, so i hope you can help me. The thing is i'm writing a custom script (not a module) that needs access to ...
Dennis Mortensgaard's user avatar
0 votes
1 answer
147 views

Accessing variable_get when loading bootstrap from an external file

I am loading the core drupal 7 components through an external file by loading bootstrap. While the core drupal functions work properly, when I try to access variable_get I keep getting the default ...
John's user avatar
  • 215
2 votes
0 answers
138 views

Returning the userId from an external script

I have a very simple external php script which will not return the userId. The script is posted below: <?php include_once "/includes/bootstrap.inc"; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); global ...
total_noob's user avatar
0 votes
2 answers
94 views

Create a script page for handling ajax

I am a bit confused on the appropriate way to generate a drupal page for handling ajax posts. For example I'm creating a custom module that has favorites buttons. When a user clicks the button the ...
John's user avatar
  • 215
2 votes
3 answers
2k views

Show a PHP page in drupal 7

I have a php script that does some querying and book keeping of drupal tables. How can I run this php script directly from the url? The script uses drupal functions so I guess it should be aware of ...
open_sourse's user avatar
0 votes
1 answer
53 views

How to create a script file

I want to create a script file that I can call using a form on submit. For example I can use: action="action.php?uid=1&method=deleteuser" This would trigger the script to result in the function ...
John's user avatar
  • 215
0 votes
1 answer
1k views

Submit to external url via Ajax & get return

I need a Drupal form to submit a file to an external server using ajax. I have done the form using Form API and I am able to submit it via Ajax, But the Drupal throbber never stops and I am not able ...
esafwan's user avatar
  • 1,348
0 votes
0 answers
69 views

Inserting user registration fields for app development

I need to insert the value as below.. but not working.. $fields['field_clinic_hospital_location_d']['und'][0]['field_telephone_number']['und'][0]['value'] = $telnum; I am inserting the user ...
J Sinha's user avatar
  • 355