Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've been following the issue #822952: "Edit meta tags" permission for each content type which currently 'needs work'. As a temporary solution I've created a module to hide the meta tags form as follows:
For the user page:
function MY_MODULE_form_user_profile_form_alter(&$form, &$form_state)
{
unset($form['nodewords']);
}
And for content types:
function MY_MODULE_form_alter(&$form, $form_state, $form_id)
{
if (isset($form['type']) && $form['type']['#value'] == 'banner') {
unset($form['nodewords']);
}
}
The above hides the form successfully for the user edit pages but I can't get this to work on the 'content type' edit pages. Any idea what I'm doing wrong?
Thanks.
Comments
Comment #1
Dave ReidYou are aware that using the latest 6.x-1.x-dev code that a user has to have the 'administer meta tags' or 'edit meta tags' permission in order to even see the fieldsets right? That should take care of this - you can ignore the form otherwise.
Comment #2
sittard CreditAttribution: sittard commentedPerhaps I should have been a bit clearer. I only added the user hook to illustrate the fact that the hook_form alter worked on the user pages and not on the node edit form.
Thanks for your help.
Comment #3
Dave ReidMake sure your module's weight is set to run after nodewords, which has a default weight of 0. That may be why you're not able to unset the nodewords fieldset, as it hasn't been added yet.
Comment #4
sittard CreditAttribution: sittard commentedGood suggestion, changed the module weight to '10' and cleared all caches but still no effect. I can alter the appearance of other forms with my custom module but just not nodewords.
Comment #5
quicksketchI know this question was never answered, but after months and months of no activity, I'm closing it. Generally support on how to write custom code isn't really a question suitable for module issue queues.