Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By _snake_ on
Hi,
I have a javascript file which uses JQuery to do AJAX. Well, I want to know if it is possible to pass "user id" to the PHP file to return different results depending on user's role.
Thanks
Comments
you could use Drupal.settings
you could use Drupal.settings to expose the current user id to js scripts.
In your module
And then in your js, access the uid like this:
----------------------
Nick Santamaria
Side Effects of this Solution
Hi, I was wondering as this has to be written in the init hook so will it require disabling and enabling the module for this code to work.