Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created April 2, 2010 01:04
Show Gist options
  • Save bangpound/352602 to your computer and use it in GitHub Desktop.
Save bangpound/352602 to your computer and use it in GitHub Desktop.
openidonly_link_alter
<?php
/**
* Implementation of hook_link_alter().
*
* When comment links are displayed, the user/register link is displayed when
* registrations are permitted. Here the $conf global is brought into context,
* the setting is captured in a local variable and the loaded value in $conf
* is changed to 0. This tricks theme('comment_post_forbidden') into displaying
* only a login link. The original value is returned to the global $conf array.
* The value in the database is never changed.
*/
function openidonly_link_alter(&$links, $node) {
if (!empty($links['comment_forbidden'])) {
global $conf;
$user_register = variable_get('user_register', 1);
$conf['user_register'] = 0;
$links['comment_forbidden']['title'] = theme('comment_post_forbidden', $node);
$conf['user_register'] = $user_register;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment