Hi Joachim,
That’s really kind, thanks for the offer. The custom fields plugin is ACF. As mine is a single use case and we have a fair few plugins already.. I decided to go with a more manual approach, calling a function from each restricted resource page template. In case it’s helpful to anyone and comments welcome (still figuring it out), this is only a draft and haven’t found the ‘last user record update date’ call yet but it’ll look something like this probably:
function authorise_access(){
$resource_type = get_field('resource-type');
$user_group = get_user_meta('user-group', get_current_user_id() );
$last_update = strtotime(get_user_meta(‘LAST_USER_MODIFIED_DATE‘, get_current_user_id() ));
$current_date_s = time();
$secs = $current_date - $last_update;
$days = $secs / 86400;
$permissions = [
'Type 1' => ['User group 1', 'User group 1 & 2', ‘User group 1 & 3’],
'Type 2' => ['User group 2', 'User group 1 & 2', ‘User group 2 & 3’],
'Type 3' => ['User group 3', 'User group 1 & 3', ‘User group 2 & 3’]
];
if(in_array($user_group, $permissions[$resource_type]) ){
If ($days < 366){
<style type="text/css">.advert-banner{
display:none;
}</style>
return null;
}
}
header('Location: https://'. get_site_url.'/promotion');
}
This requires a ‘authorise_access();’ call in restricted pages’ templates and using ACF to add the resource-type field and values for restrictions to compare to user groups.
This function also hides a promo div as these user groups have already signed up.
Bw
Ben