Hooks are PHP functions used to interact with the Drupal API.

learn more… | top users | synonyms (1)

1
vote
2answers
35 views

Hide authoring information programmatically in a content type

How do I programmatically hide the Authored by part in a content type using hooks?
0
votes
0answers
6 views

Is it possible to Bind Services Module Endpoint to a Scope in Oauth 2.0 Server module?

I'm working on a project where I have to bind an authorization scope to a specific endpoint as provided by Services Module. This is in a way overlooks the scope provided in request. Is it possible?
0
votes
2answers
23 views

Put a Form in the Site's Homepage

I have the item menu in my hook_menu. //Calls a function that enables creating, updating and deleting ID Templates. $items['user/%user/myid_templates'] = array( 'title' => 'MyID Templates', ...
1
vote
1answer
24 views

How can I overwrite a hook from a theme

I have a custom sub-theme of the Seven theme. The Seven theme makes some node alteration via seven_form_node_form_alter(). I would like to have seven_form_node_form_alter() not run at all or I would ...
0
votes
1answer
23 views

Is it possible to detect access to table on site db table and redirect the db query to a db shared by multiple websites?

I'm working on a project where I use a database that is common to all sites and another that is specific to each. Is there a way to detect access to a specific table on a contrib module (maybe using a ...
1
vote
1answer
16 views

Display Node edit under edit tab

I would like to know whether the "node edit form" (admin form) can be displayed under the edit tab itself using MENU_LOCAL_TASK?
1
vote
1answer
16 views

if term reference is value X in tpl.php file

I want it so that in my page.tpl.php file if the user has selected "Standard" as the "Page Type" term reference it prints an extra bit of html. I tried something along the lines of the code below but ...
1
vote
1answer
23 views

Drupal 8: How to implement hook_views_query_alter

I try to implement hook_views_query_alter in Drupal 8. I found a hint, that it has to be in my_module.views_execution.inc. I tried it, but the hook never gets called. function ...
1
vote
1answer
26 views

How to render a contact form as rendered entity

I have a question about rendering a contact form as a rendered entity. I have a field in my contenttype where form should be displayed. The field has the type Contact form. In the Manage display ...
3
votes
2answers
54 views

How to compare the already saved value of node and updated value?

I want to programmatically compare a field value of a node in hook_node_update(). How can I get the already saved and the updated values?
0
votes
0answers
20 views

If view results are odd, append the result with another row

I have 3 Views. Each have 1-9 items. The problem is that if the user adds an odd number items, I want to be able to add another. So my logic is to count the rows, if it the row count is odd, insert ...
0
votes
2answers
25 views

How to add element not appearing on the page via node_view_alter?

Given the following code: function mymodule_node_view_alter(&$build) { $node = $build['#node']; if ($node->type != 'podcasts') { return; } $build['new_section'] = array( ...
3
votes
1answer
32 views

Is this correct usage of hook_node_view()?

hook_node_view_alter(&$vars, $hook) { global $base_url; if($vars['#node']->status == 0) { header('Location: '.$base_url.'/?errCode'); } } Simple hook to redirect unpublished nodes ...
0
votes
2answers
18 views

Disable user creation at login with Simple LDAP

I have the simple LDAP module installed and running, and I would like to prevent Drupal from creating a new user after a user authenticates if it does not already exist in Drupal. I found the ...
1
vote
1answer
21 views

An invalid implementation mymodule_form_alter was added by hook_module_implements_alter

I am trying to have my module alter menu_ui functions. Changing my module's weight didnt help and I read that hook_module_implements_alter is the way to go. So, as described here I am appending my ...
0
votes
0answers
31 views

How to add div in a custom content type in teaser mode?

I am using Drupal 7 . I have content type and it is in teaser mode. Now i added code in hook_node_view. $node->body['test']['read_txt_more_less'] = array( '#type' => 'markup', '#markup' => ...
0
votes
0answers
9 views

Use AJAX to post to remote endpoint from webform

I have installed Drupal 7.4x on my server and have added a webform, this form is a type of report, a weather report with description, date, time, location, etc. When this webform is saved, I want to ...
1
vote
0answers
24 views

Using Smart IP (or similar) on cached pages

I would like to use the Smart IP module for IP detection; however, it runs its detection in hook_init(), which does not run on cached pages. I am not married to the module. I have tried to pull out ...
0
votes
1answer
21 views

hook_user_insert not working

I am new to drupal. When user register into my website I need to get the users details and passed to a thirty for server . I am trying the following hook, function ...
2
votes
3answers
226 views

Programmatically do something when a node is updated

I want to do something when a node gets updated. To keep it simple, lets say display a drupal message. hello_world.routing.yml hello_world: path: /node/{node} defaults: _controller: ...
0
votes
1answer
11 views

how to modify the path with hook_menu_local_actions_alter

when I add the hook_local_actions_alter to my module, I can see that the node.add.page link shows up on certain pages as below. how can I modify this so that this also show up on a different path in ...
1
vote
2answers
19 views

How to call template when Custom form is submitted?

I have created custom form and on submit of that form, I need to fetch data from database and need to display that content in well structured format in different template. I am able to create form, ...
2
votes
1answer
26 views

How reliable is hook_post_action module?

I am using this module under Drupal 7 to execute some code after nodes of a particular content type get updated. My question, is this module reliable? Would the post save event be called every time my ...
0
votes
1answer
16 views

Content type access permission by user role

I have created 4 different content types and all except only one content type are visible to every user. Here, I am not using any type of access module like content access, field permission or ...
0
votes
1answer
49 views

Storing a URL from a basic page using a custom module

I created a basic page at http://example.com/[company]/[customer]?id=2. I want to store this URL in a global variable for string manipulations within a custom module. I succeeded to retrieve the URL ...
0
votes
0answers
6 views

Query filter assign sub query to one field value in Drupal View

I have stuck in this issue from the last two days. Please help. I want to assign the following query . $qr = "( select subconfigcode.field_subconfigcode_value AS configcode FROM node node LEFT ...
0
votes
1answer
26 views

Hook is not invoked

I have a function I want to execute when a user finishes a quiz. function wilson_random_task_quiz_finished($quiz, $score, $session_data) { // ... } When a user finishes a quiz, I think the hook ...
0
votes
0answers
28 views

Custom page callback gave 404 but the page content is correct

I have a page callback that shows users' related content and displays a custom login form if user is not logged in. The site worked in another server, but today I migrated it to this laptop, and the ...
1
vote
1answer
14 views

How to make commands invoked by drush_invoke not to fail after adding extra option?

I've added new option into drush command as suggested here: function hook_drush_help_alter(&$command) { if ($command['command'] == 'features-revert-all') { $command['options']['cleanup'] = ...
0
votes
1answer
11 views

How to add extra option to the existing drush command?

I'm trying to add extra option to the existing command as below: /** * Implements hook_drush_command_alter(). */ function MYMODULE_drush_command_alter(&$command) { if ($command['command'] == ...
1
vote
1answer
24 views

How to overridden command via hook_drush_command_alter?

I'd like to override command using hook_drush_command_alter before run as below: /** * Implementation of hook_drush_command_alter(). */ function policy_drush_command_alter(&$command) { if ...
0
votes
2answers
20 views

What hook can access every field label at once and change the label of one?

I am trying to change the display label of one field on a node (not the form), depending on the value set in another field in Drupal 7. I don't want to change the label in the database, just on the ...
0
votes
0answers
34 views

How to reindex a particular node in Drupal 8?

I want to index particular node on update, insert how to do it in Drupal 8? In drupal 7, we use the function function _node_index_node() I want to use the same function in drupal8 for my Drupal 8 ...
0
votes
1answer
29 views

What is significance of confirmation page before deleting a node? [closed]

I want to know what exactly usage of node confirm delete page except to avoid miss configuration.
0
votes
0answers
28 views

Hook before the file insert, before the file come on the server?

I want alter the URI's files before they are stocked in the server. The file insert, I mean, everywhere/time a file is uploaded via Drupal (all insert file process, not only when an user add a file ...
0
votes
3answers
26 views

How to call functions from another module in hook_language_negotiation_info()?

I am writing a new custom module which is dependent on geoip module. I'm trying to add another language negotiation in the language detection configurations which would trigger a callback function ...
0
votes
1answer
25 views

Simple debug results in internal server error

All I want to do is print a view out so I can check the variables and see the structure of what's being created but it results in an internal server error. I'm using Acquia Dev Desktop. I've checked ...
0
votes
0answers
9 views

Modify the registration page in the membership entity module

I am new to drupal. I would like to remove some of the fields on the registration page of the Membership Entity module and add others. The new fields that I add need to be saved into the database. ...
0
votes
1answer
44 views

Alter field value before render

In Drupal 8, I was thinking that's a simple task but it's not : function hmytheme_preprocess_field(&$variables, $hook) { $element = $variables['element']; if ...
3
votes
1answer
28 views

Supressing “Undefined variable: variables in module_block_view()” without hiding the notice

I tried to create a simple custom block inside a custom module. there is a notice that inform me about undefined variable, but the block rendered properly. I am not sure where the mistake in the code ...
5
votes
3answers
51 views

How can I programatically prevent users from saving the same entity twice in a row?

My server sometimes gets overloaded, and sometimes people press the "Save" button on an entity creation page several times, which results in multiple versions of the same entity being created. So, I ...
0
votes
1answer
28 views

How to add js in view created by interface

I want to create a new button control in my ip_geoloc leaflet map. So, i created a view by using the drupal interface -> /admin/structure/views/view/markers_admin/edit And now i want to set a custom ...
1
vote
2answers
38 views

hook_load vs. hook_node_load?

Can someone explain clearly the difference between hook_load and hook_node_load? hook_load says it is a "node-type-specific hook". What does that mean? hook_node_load actually has a types parameter.
1
vote
1answer
15 views

How to alter command being run by drush_invoke?

When you run drush features-revert-all command, it can be altered using hook_drush_command_alter (&$command). However during run it's invoking another command by: drush_invoke('features-revert', ...
-1
votes
1answer
26 views

Convert hook_menu in drupal 8

I have a hook_menu as follows : /** * Implementation of hook_menu(). */ function conditional_fields_menu() { $items = array(); foreach (node_get_types() as $type) { $content_type = ...
1
vote
0answers
36 views

How to create private links to unmanaged files ?

I have created my own module with custom block to display private downloads to authenticated users. The downloads files are provided by 3rd-party system and stored in private folder of Drupal ...
0
votes
1answer
24 views

How do I send email to Users of a Role that belongs to Country using Rules?

I'm using Profile2 module to assign a Country to a Role. For example I have: User1 | Role: "International Members" | Country: "UK" User2 | Role: "International Members" | Country: "Poland" User3 | ...
0
votes
0answers
25 views

How to overwrite form submit? “Please enter some keywords” - Cant see my error

I have managed to get quite a few modules up and running and i'm now on my last sprint and got caught off guard by this small issue. I simply want to change: if ...
0
votes
0answers
19 views

how to create new drupal-wall node through custom module?

I have using drupal wall contributed module to posting purpose,and these posts create through custom module, i have used node_save() to create a new nodes. but problem is instead of user/author name ...
0
votes
0answers
25 views

Fatal error: Call to undefined function node_type_get_names() in C:\xampp\htdocs\kfd\modules\comment\comment.module on line 119

I am getting this error after installing one custom module i removed that module but still i am getting the same error message. Actully i defined same function accidentedly in two module. I install ...