Ads per role
| Project: | Advertisement |
| Version: | 6.x-2.0-rc1 |
| Component: | ad_channel module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Hi! I have a site which is based on roles to identify the user's profile who is surfing it.
First I created different ads groups for each role and I put the blocks one below the other, but if one user has two or more roles, he views two or more ads one below the other.
Then I installed the Nodeaccess module. I thought if I created only one group for all the ads and I grant view permissions for each role in each ad, the 'ad block' would displays randomly the permited ads. This module works perfectly with all content types, but not with Advertisment Type.
I didn't explore the ad module deeply because is huge! So I don't know if this feature already exists, but it will be a great feature!
My idea:
In Ads Creation Form add some checkboxes with the roles (defined at ads settings in administration page). The selected roles must be able to see the ad. If none role is selected, all roles must be able to see the ad.
thanks for taking time to read me :)

#1
This is not currently possible. It believe it would be best added as a feature to the ad_channel module, I'll leave it open to review at some point if I find the time - patches welcome.
#2
Hi, i think i understand what your trying to do, and if i do, i wanted to do the same thing. ive done very little php work, but have programmed in other languages. Anyway, this is working for me...
in whatever .tpl.php files i want to use it in, i place an ad as follows:
<?phpglobal $user;
if (!(in_array('adfree', $user->roles)))
{
print ad(NULL, 1, array('nids' => '66')); ;
}
?>
this particular example will show the advert unless the uesr has been assigned to the adfree role. and it will show add at node id 66.
To display an ad to a prticular role instead of to all but a particular role, use:
<?phpglobal $user;
if ((in_array('ads', $user->roles)))
{
print ad(NULL, 1, array('nids' => '66')); ;
}
?>
where node id 66 is the advert you want to show, and ads is the user role to show it to.
alternatively, im assuming you can create a new html ad, and put the following:
<?phpglobal $user;
if ((in_array('ads', $user->roles)))
{
print [ad code here]
}
?>
replacing the [] with your ad code. should also work with the first example excluding it from a certain role.
Hope this helps...
#3
Hi Pingu,
thank you very much for this code but I feel as if this takes much of the flexibility of the module - for example if I want to choose embedded ads which are automatically embedded in content after the Xth paragraph and where I can choose after which paragraph.
Is there anyone working on this issue?
Greez,
Tobias
#4