I have described my use case here in the Ajax module. I would be grateful if you could tell me whether you think this could be done using Ajax Login/Registry (for example by replacing the standard link to add comments for an anonymous user in me theme, with a link to Ajax registry).
Many thanks, JG

Comments

compujohnny’s picture

Hi,

Yes its absolutely possible,

With the new APIs in the new release of the Ajax Login/Register module,

Make sure you upgrade to the latest version,

Just add the following code to your theme's template.php file,

function YOURTHEMENAME_comment_post_forbidden($node) {
  global $user;
  static $authenticated_post_comments;

  if (!$user->uid) {
    if (!isset($authenticated_post_comments)) {
      // We only output any link if we are certain, that users get permission
      // to post comments by logging in. We also locally cache this information.
      $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));
    }

    if ($authenticated_post_comments) {
      // We cannot use drupal_get_destination() because these links
      // sometimes appear on /node and taxonomy listing pages.
      if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
        $destination = 'destination=comment/reply/'.$node->nid.'#comment-form';
      }
      else {
        $destination = 'destination=node/'.$node->nid.'#comment-form';
      }

      if (variable_get('user_register', 1)) {
        // Users can register themselves.
        return t(ajax_register_get_login_link($attributes = array(), $destination).' or '.ajax_register_get_register_link($attributes = array(), $destination).' to post comments');
      }
      else {
        // Only admins can add new users, no public registration.
        return t(ajax_register_get_login_link($attributes = array(), $destination).' to post comments');
      }
    }
  }
}

Hope that helps,
Thank You,

joel_guesclin’s picture

That's great - many thanks indeed

compujohnny’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.