Skip to content

Instantly share code, notes, and snippets.

@froboy
Created April 19, 2017 20:08
Show Gist options
  • Save froboy/915d7921c0cacdee923008adb188e180 to your computer and use it in GitHub Desktop.
Save froboy/915d7921c0cacdee923008adb188e180 to your computer and use it in GitHub Desktop.
Drupal (7) VBO snippet - Turn on pathauto & Remove redirects
// This script can be run via Views Bulk Operations in the "Execute arbitrary PHP code" op
// This is, obviously, at your own risk. I'd take a db backup first.
// Force "Generate alias automatically" to be TRUE, then save the node.
$entity->path['pathauto'] = TRUE;
node_save($entity);
// Remove any stray redirects so that there's one true URL
$deleted = db_delete('redirect')
->condition('redirect', 'node/' . $entity->nid)
->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment