Restrict access by date user is created

Created on 11 February 2015, over 10 years ago
Updated 25 September 2025, 11 days ago

Hello Folks,

Great module thanks. I have an additional requirement that has come up after the fact which I've detailed on stackexchange here:
https://drupal.stackexchange.com/questions/146520/restrict-node-view-to-users-by-registration-date

In short I'm trying to:

  • Restrict view access to certain custom node types by the date the user registered
  • The user would be able to see restricted content created in the month they registered and any future month while their user account is active, but nothing before the date the account was created
  • There is existing content restrictions and functionality for the same users on the same content. Only certain roles can see selected node types and this is selected when the user is created (manually). This is managed by nodeaccess

I used the suggested code from a kind helper there but it's not working for me. I created an enabeld a custom moduel with the following:

<?php

function node_access_byregdate($node, $op, $account) {
  $type = is_string($node) ? $node : $node->type;

  if ($op == 'view') {
    global $user; // get current user
    // check user register date
    if ($user->created < $node->created) {
      return NODE_ACCESS_DENY;
    }
  }

// Returning nothing from this function would have the same effect.
  return NODE_ACCESS_IGNORE;
}

Any assitance would be greatly appreicated. Thanks in advance.

💬 Support request
Status

Postponed: needs info

Version

1.4

Component

Code

Created by

🇬🇧United Kingdom BrendanP

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024