Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3482074
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:31:02+00:00 2026-05-18T10:31:02+00:00

I would like to override the comment_save function. Is there a way to override

  • 0

I would like to override the comment_save function. Is there a way to override it so I can add in my functionality?

Is creating a trigger such as http://drupal.org/node/375833 the best way? That doesn’t seem very reliable since it happens after the fact.

BTW, this is in D6.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:31:03+00:00Added an answer on May 18, 2026 at 10:31 am

    It’s tricky. First off, I’d suggest instead going and seeing if you can manage what you need by using hook_comment ( http://api.drupal.org/api/drupal/developer–hooks–core.php/function/hook_comment/6). It’s really more of what this is needed for.

    If you really need to override comment_save, then often a good choice is to look around at what things call it. For this situation, you’re lucky – comment_save only gets called in one place, on line 1542 of comment.module, inside of comment_form_submit.

    Now, comment_form_submit is a form submit function – instead of replacing comment_save, we can instead make our own custom version of comment_form_submit (and for argument’s sake, we’ll assume we’re working in a ‘custom_module’ module) – so what I would do is create a new function called custom_module_comment_form_submit, which calls the variant of comment_save that I’m interested in using, and then use hook_form_alter() ( http://api.drupal.org/api/drupal/developer–hooks–core.php/function/hook_form_alter/6 ) to set the $form[‘#submit’] to replace the value ‘comment_form_submit’ with ‘custom_module_comment_form_submit’.

    This isn’t perfect – if you install another module that uses comment_save, then you’ll need to find a similar workaround. And if a bug or security hole is found in Drupal that is fixed in the part you’re working around here, you won’t get that security hole fixed in your code. But if you absolutely must replace comment_save, this is pretty much the only way to do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to temporarily override the kill-new function. I have a way I
I would like to override a generic function in a subclass, as follows: Superclass:
I would like to override custom user template in my Drupal 7 installation. The
I would like override OnPreInit asp.net event and add code to it from library
I would like to override the List object in C# in order to add
I would like to override Tekerik's javascript function. To do that I want to
I have a class MyClass, and I would like to override the method ToString()
Would like to be able to set colors of headings and such, different font
I would like to generate such a formatted head comment with a shortcut //##########################################################
I would like to override the buttons of a datepickerdialog case START_DATE_DIALOG_ID: DatePickerDialog datePicker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.