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 7568623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:58:20+00:00 2026-05-30T14:58:20+00:00

I have created two actions in code, one simple and one advanced. function userbeep_action_info()

  • 0

I have created two actions in code, one simple and one advanced.

function userbeep_action_info() {
    return array(
        'userbeep_beep_action' => array(
            'type' => 'system',
            'label' => t('Beep annoyingly'),
            'configurable' => FALSE,
            'triggers' => array('node_view', 'node_insert', 'node_update', 'node_delete')
        ),
        'userbeep_multiple_beep_action' => array(
            'type' => 'system',
            'label' => t('Beep multiple times'),
            'configurable' => TRUE,
            'triggers' => array('node_view', 'node_insert', 'node_update', 'node_delete')
        )
    );
}

Now the simple action (i.e. the non-configurable one) will appear in my Triggers menu automatically, but I need to create the advanced one in admin/config/system/actions before I can use it.

What I’d like to do is have my module automatically create the advanced action. There are two ways I can see this working:

1) Add something to an .install file to install and uninstall upon loading the module.

2) Package these settings using Features

Ideally, I’d like to do this programmatically using 1), but I’m also keen to learn about Features. I installed the module but saw no obvious way to do this.

Moving forwards, would there also be a way to package / set up the Trigger using these actions so that the user doesn’t have to set this up manually?

  • 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-30T14:58:21+00:00Added an answer on May 30, 2026 at 2:58 pm

    1) You can use the Actions API methods – actions_save and actions_delete for this. (See includes/actions.inc).

    hook_install(),

    // Action configuration parameters that you can also set by clicking on the 
    // Configure link that shows next to a configurable action in
    // admin/config/system/actions
    $config['beep_count'] = 10;
    $config['beep_file'] = 'sound.mp3';
    $aid = 
      actions_save(
        'userbeep_multiple_beep_action', // Name of the action callback method
        'system', // Action group
         $config, // An array of key-value pairs
         t('Beep multiple times'), // Action label helpful in the Trigger UI
         NULL // Create a new action
      );
    variable_set('my_module_actions', array($aid));
    

    hook_uninstall(),

    $aids = variable_get('my_module_actions', array());
    if (!empty($aids)) {
      actions_delete($aids);
    }
    

    2) Does Features support exporting actions? For packaging non-configurable actions, hook_action_info() is good enough, I feel.

    3) Again, using code, you can explicitly assign actions to triggers by adding entries to the trigger_assignments table as shown below:

    $query = db_insert('trigger_assignments')->fields('hook', 'aid', 'weight');
    $hooks = array('node_insert', 'node_update', 'node_view', 'node_delete');
    foreach ($hooks as $hook) {
      $query->values(array(
        'hook' => $hook,
        'aid' => 'userbeep_multiple_beep_action',
        'weight' => 0
      ));
    }
    // Multi-value insert
    $query->execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two forms in my Windows Application. One Form acts as a
I have created two JavaScript files. One file is "validators.js" and the other is
I'm having a problem with mixing managed and unmanaged code. I have created two
I have created an alert view with two buttons using the following code: UIAlertView
Well as I have posted earlier too...I have created a site in two languages.One
In my controller I have two actions called Friends. The one that executes depends
I have created two buttons with pagescrolling. Now by clicking on one button the
I have created two files: tunables.h #ifndef TUNABLES_H #define TUNABLES_H void tunables_load_conservative(); void tunables_load_aggressive();
Let's say I have created two objects from class foo and now want to
I have created an item swapper control consisting in two listboxes and some buttons

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.