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

learn more… | top users | synonyms (1)

6
votes
1answer
17 views

hook_menu_alter when using Organic Groups

I want to change the menu button on my main nav bar depending if the user is or isn't a member of a group. I need one button to 'register' if the user isn't part of a group and that same button ...
2
votes
2answers
30 views

How can I perform an operation programatically when the value of a user field is changed?

On my user accounts, I have a text field, field_nickname. Users can change this at any time. When they do change it, however, when the user account is saved I want to copy the old value for ...
-2
votes
1answer
14 views

Need to create a link to call a function in a module [on hold]

Want to create a link "Click Here To..." that will call a function in a module. What is the best way to achieve that? Thanks!
1
vote
1answer
18 views

Views settings options in my custom search page

I have followed this tutorial. I have selected the blocks option instead of page option in views as I want to add it as a block in the organic group homepage. How do I restrict the search using ...
0
votes
1answer
10 views

How can I hook into entityforms being submitted?

I've installed entity forms. I have made a form. I would like to fire some code when a user fills out and submits the form I have created. I do not know how to do this. I don't know which hook to use, ...
1
vote
1answer
19 views

hook_views_query_alter if date field empty sort with another field postdate

I have a view that show all contents of type NEWS NEWS has like fields : Content = Title Scheduler = publish-on and in sort criteria : I want sort contents with two option : With scheduler ...
-1
votes
1answer
18 views

Trying to modidy a menu hook_menu_alter

What is the best way to add a link to the user menu for a menu defined in my custom module?
1
vote
1answer
33 views

How to set a value programatically only when a content type is saved for the first time?

I'm trying to record the user agent string into a text field (field_useragent) the first time a content type is saved. This is what I tried: /* * Implements hook_ENTITY_TYPE_insert() */ function ...
1
vote
1answer
32 views

How to send email after a node field gets updated by admin?

I need to send an email notification to the node editor (reviwer/moderator) when an admin changes a (custom) field. I've added the list of editors as a field in node form. The nodes will be created ...
3
votes
1answer
81 views

Hide node title on front page using template.php not css

I'm building a drupal 7 bootstrap sub theme and want to hide the title of the nodes if there on the home page. I don't want to use css as its only hiding it I want to have the titles not render at ...
0
votes
2answers
21 views

How can I alter the title of a node upon save?

I want to automatically set the title of nodes with content type ABC to the node ID. (I want to hide the title field from the form in the UI, and I don't care about titles for this content type.) ...
0
votes
0answers
14 views

how i can display the weekly view in manage availability in rooms_availability?

Hello i installed Rooms module, and enabled all dependencies, now when i edit a bookable unit and when i click in manage availability i can edit availability per month. But I do not want a monthly ...
0
votes
3answers
45 views

How to call a drupal custom module function from a basic page? [closed]

* if i will click a input button in basic page a particular function should be called from my custom module. I have already enabled my module in my instance.* <?php $name = $_POST['name']; $pwd ...
1
vote
1answer
27 views

Return value on a submit handler

Below is a hook from the LinkedIn Integration module. Then I have a hook form alter in my module and it's all setup and ready to go to call a submit handler. When the user goes to authorize ...
1
vote
1answer
18 views

Hook that runs on admin pages

I'm trying to find a D7 hook that runs on admin pages (admin/people/create to be exact). I've tried many hooks, but none of them seem to be firing on admin pages. What is the best way to detect if ...
0
votes
1answer
29 views

Additional twig suggestions for menus in Drupal 8

Unlike other elements, the base twig suggestions for menus are only "menu.html.twig" and "menu-[menu_name].html.twig". I am aware that I can generate additional suggestions through the hook ...
0
votes
0answers
18 views

Drupal Booking a week (days and hours available) (reservation per day/hours and availibility per days/hours)

I look for a module similar to 'rooms availability' but I want to be able to choose availability by days and hours of each day. the principle is: each lawyer consulted her profile, a calendar that ...
0
votes
2answers
20 views

db_update with a hook

Have a field called url_time in the users table. I have this function in place, though it does not update the table on the else part. Does this code look correct? function ...
2
votes
1answer
30 views

Alter main menu button text and URL path depending on OG Role

I know you can change menu links depending on drupal based roles (authenticated, non authenticated...) and by using Rules module also. I am using Organic Group roles and I am having difficulties in ...
1
vote
1answer
19 views

Have to hook into a function from a module

I am using the LinkedIn Integration module and have created a custom module to add some functionality. Please see the linkedin.inc file at line 17 - function linkedin_access_token($account) When a ...
0
votes
0answers
8 views

How to copy location data to address field programmatically for users?

I have a site which needs to have both geofield and location data because we are using both Gmap and OpenLayers. I want to prevent the redundancy of forcing the users to enter the data into both ...
3
votes
1answer
28 views

What do I have to do to get hook_form_alter picked up?

Trying to move from Drupal 7 to Drupal 8. First step is to get a custom module with hook_form_alter() and the Devel module working so that I can see how bad I am messing things up. To do so, I made ...
3
votes
3answers
45 views

Count number of nodes to be output

I'm trying to figure out how many articles( nodes? ) will be displayed in a listing on our website, to use it to add classes to the elements that are rendered, so one can easily have different styling ...
1
vote
2answers
82 views

How to override page title by content type in Drupal 8

I'm using the pagetitle core module to render a page title. However, for certain content types I want the page main title to be the content type label (e.g. "News") and not the node label (e.g. ...
0
votes
1answer
34 views

Where is the code for added user registration fields? [closed]

I've added a few extra fields relevant to my interests to the user registration form. The problem being, I'd like to insert a db_insert function to make use of those fields, but I don't know where the ...
3
votes
1answer
46 views

Correct usage of hook_user_login and hook_user_presave for saving data to user

I have a custom module that syncs LDAP-data to custom user fields (every 24 hours, depending on when the user logs in). Everything seems to be working, but I'm not an expert on PHP and Drupal hooks so ...
0
votes
1answer
16 views

Hook to track commerce product category view

I am creating a drupal commerce module for tracking users. I want to access a hook in drupal commerce on product category page. Went through most of the documentation but was not able to find the hook ...
0
votes
0answers
17 views

Newly added field using hook_views_pre_render(&$view) not showing in Views block [closed]

function owner_only_fields_help_views_pre_render(&$view){ file_put_contents('C:\Users\pc\Desktop\debug.txt', print_r("$view->name", TRUE)); if($view->name == "profile_showusers") { ...
0
votes
2answers
36 views

The hook_node_insert not working in Drupal 8

The hook_node_insert function is not working after the node insertion in drupal 8. When I'm trying to get the node details in the node_insert function, it's not working. My code is given below: use ...
0
votes
2answers
28 views

hide repeated data from my view table for some specific field

****how can hide repeated data from my view table. i want to print employee Id and name field only once for each group. can you please help me out.**** I am fetching two table in view using ...
0
votes
0answers
15 views

how i can display the file path in imce?

i want display the file location path in the imce : i opened the imce-file-list.tpl.php and i found that : <tr id="<?php print $raw = rawurlencode($file['name']); ?>"> <td ...
2
votes
2answers
37 views

Drupal 7 sync one menu items into other menus

I have a Drupal menu called Top-Nav which I use for my Top Navigation with the following 6 menu items(for example) Home a b c d e Each of a, b, c, d and e have sub items. I also have ...
0
votes
0answers
15 views

Use hook_webform_submission_presave () to edit the SID of a Drupal webform

I'm working with Drupal 7 and I've created a module called uvic. What I'm trying to do is to restart the SID when a form is cleared but it isn't working, what I'm doing wrong? function ...
0
votes
0answers
20 views

how to add “remove” button in widgets items of entity reference view widget field?

i have a problem, i want to add a button "remove" for each items, this is the code of the module : /** * Implements hook_form_BASE_FORM_ID_alter(). */ function ...
1
vote
1answer
23 views

How to iterate through an object returned by fetchAll?

Since fetchAssoc was returning only one row, i was forced to use fetchAll. The problem is fetchAll returns the data as an array of objects. Iterating through them is kind of painful, not impossible ...
0
votes
0answers
26 views

How to override views-view-field.tpl.php in custom module?

I am trying to override views-view-field.tpl.php in my custom module as suggested in override views-view-fields.tpl.php in custom module but looks like it's syntaxes are old. My codes are like: In ...
0
votes
1answer
38 views

Custom date range format on a node by node basis

I'm working on a way to alter the way a date field, field_node_date, is formatted when rendered. Currently, on the content type I'm working on, the Long format is being used (e.g. Monday 18 January ...
0
votes
1answer
27 views

Payment method to cart page

I need to move the payment method from the checkout page in drupal commerce and embed it into the cart page. is that even possible? I have been finding some resources and it does not lead me anywhere. ...
1
vote
1answer
34 views

hook_form_user_register_form_alter() does not customize user registration form

I have implemented a hook_form_user_register_form_alter(). function hook_form_user_register_form_alter($form, $form_state, $form_id) { $form['account']['name']['#description'] = 'This is your login ...
0
votes
1answer
24 views

create and save data to a file in the files folder from cron

I currently have some working example code where when a URL path i defined using hook_menu has been passed; My custom module will use file_get_path() to pull a txt file from another ftp server. It ...
0
votes
1answer
14 views

AJAX event returns same data always

So, this is a simple form, and what the ajax call back does here is that it returns the value of a field that's being changed. The problem is that, only the value of the first change is returned. If ...
1
vote
1answer
28 views

How to handle hook_node_validate?

I am using some contirb module and in which hook_node_validate is used. I am overriding the function passed in hook by running CUSTOM_MODULE_node_validate. But the contrib module validate also keeps ...
0
votes
1answer
16 views

What's the usage difference between element_validate and validate hook?

From what i've learned today, there are two ways one can go about validating input. One is the #element_validate field which is passed along the form hook, and the other is the validate hook. Why ...
0
votes
1answer
32 views

form_submit hook not firing

The title says it all. I've created a form, but the submit hook isn't triggered once the form is submitted. <?php //Create raffle form function raffle_create_form() { //Basic raffle info ...
1
vote
1answer
11 views

Access argument string for all administrators to access menu

I have implemented a hook_menu method in a module i'm writing. The problem i'm facing is, i'm not able to pass an access argument that grants access to all the administrators. The only one able to ...
0
votes
0answers
12 views

Create an article translation(s) via hook_form_alter?

I would like to submit an article in English but when I press submit button I would like to create its translation(s) as well. Can I do it with hook_form_alter? I have this now: /** * Implements ...
0
votes
0answers
16 views

Webform onchange added with hook_form_id_alter

I have a webform on a Drupal 7 site I am working on with a form ID of 144. I have a module that alters this form to add default values to the fields within the webform. This is all working fine. I now ...
0
votes
0answers
31 views

How i can show a specific term of check box in drupal using conditional

I have a bank form to do it is: the user at the beginning, he had a "status" form "radio button" Status ---> Young, Employee, Business Man each status: young had such offers and questions if the ...
0
votes
2answers
32 views

hook_node_access($node, $op, $account) not working

I'm using drupal 7.41 module: Devel I created module_template module. function module_template_node_access($node, $op, $account) { kpr($op); kpr($account); } But when I view or edit node not ...
1
vote
1answer
21 views

Adding print friendly link on specific nodes

(I have already posted this question on StackOverflow, but I then discovered this forum, which seems to be a more appropriate place for this question.) I have also read all the similar questions on ...