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

  • Home
  • SEARCH
  • 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 3630998
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:20:28+00:00 2026-05-19T00:20:28+00:00

I created a module to do all my form altering called form_mods. It’s working

  • 0

I created a module to do all my form altering called “form_mods”. It’s working for most situations but not for the Taxonomy page.

I’m targeting the form id of “taxonomy_overview_vocabularies”. I’m trying to hide the link “edit vocabulary” for roles of “webmaster” and “dj”.

My code is unsetting the $form array correctly, but Drupal is still displaying the “edit vocabulary” link.

function form_mods_form_alter($form, $form_state, $form_id) {

    if($form_id == 'taxonomy_overview_vocabularies'){

        global $user;
        $hide=0;
        $hideArray = array('webmaster', 'dj'); 
        foreach($user->roles AS $key => $value){
            if(in_array($value, $hideArray)){
                $hide++;
            }
        }

        if($hide){
            foreach($form AS $vocab){
                //print_r($vocab);
                if(isset($vocab['edit']['#value'])){
                    unset($vocab['edit']['#value']);
                }
            }
        }
    }
}
  • 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-19T00:20:28+00:00Added an answer on May 19, 2026 at 12:20 am

    Very small PHP mistake,
    when you want to change array members in a for each statement you have to pass them by reference & foreach($form AS &$vocab) otherwise the $vocab would be just a copy of the array

    foreach($form AS &$vocab){
            //print_r($vocab);
            if(isset($vocab['edit']['#value'])){
                unset($vocab['edit']['#value']);
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an executable module created by third party. I would like to inject
I have created a Python module that creates and populates several SQLite tables. Now,
I'm creating an API for a module and after I created several methods inside
When I extract files from a ZIP file created with the Python zipfile module,
Hi I need to create a module in drupal to display some data, not
i have created a module with this among others this function in it: <?php
Background information: I'm in my admin module, and I created a view helper in
My website has a setup whereby when the application starts a module called SiteContent
I'd like to create several modules that will be used in nearly all scripts
I'd like to create a module in DNN that, similar to the Announcements control,

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.