I see this issue has been raised for the 5.x version, but not 6.x.
The "My Classified Ads list" tab shows up in a user's profile regardless of whether the user can or cannot create ads. I've looked at the previous discussions, so I understand why this is happening. Here's why I don't want this to happen: I would like to use Classified Ads as a "premium" feature for my site...a bonus they get for doing other things. They will use the Classified Ads to put up special offers and the like.
Access to creating and editing Classified Ads is role-based.
This pretty much falls apart if every user sees a "My Classified Ads list"....even a non-functional one...when they access their own account. It's also confusing; a tab item for a list of ads that will always be empty.
It seems this should be an easy tweak, but I haven't been able to figure it out. Is there a simple way to turn it off for a user's own profile when the user doesn't have access to creating ads?
Comments
Comment #1
milesgillham commentedFixed in -dev. Will be in next release. Users will only see a "My Classified Ads List" if they have permission to create, edit, or reset ads.
Cheers,
Miles
Comment #2
drupup commentedThanks. Maybe I'll be able to crack open the .module and see how you did it.
I'll download the -dev and check it out. This is a handy little module. I notice you're considering re: integrating with Ads, but to me, as an end user, the functions are quite different. I've got my ad blocks. Classified Ads gives me an additional, and quite useful, content type. Just my two cents...and God knows, we all know what the dollar's worth these days.
Comment #3
milesgillham commented@drupup: Just pull down the alpha6 release, the modification is included in that. All I've done is surround the user hook with a check to see what permissions they have. Very simple change. You need to be sure to flush your cache though.
I'm no longer considering any merge with the Advertisement module, the modules aren't on a convergent path at this time. I took over as maintainer of the Views module for Advertisement to start to see how it ticks and realised that they're chalk and cheese. I've been short of time the last few months but am keen to make a big push soon on new features for ed_classified and get it into Beta.
Cheers,
Miles
Comment #4
drupup commentedhmmmm.....still showing. I've double-checked permission setup, flushed the cache (you GOTTA flush that cache!). Let me keep testing; I'm at the end of my day here in the 'states and ready to call it a night.
I think I've found a wee bug: if no ads have been created, the Classified Ad module forgets to print all the content, which for my site makes for a bit of formatting trouble, since without all the
I end up with a headless rounded rectangle. Traced it to line 458 in the function ed_classified_page. If I changed this:
$ads[] = node_load(array('nid' => $node->nid));
}
to this:
$ads[] = node_load(array('nid' => $node->nid));
}
if (!isset($ads[0])) {
$ads[0] = 'There are no ads available in this category';
}
In other words, give it SOME content, and I got the full writeup, though it put "n/a" rather than my text. As you can tell, I'm a hacker, not a programmer. Sorry if this should have been a separate issue.
Comment #5
drupup commentedOkay, came back, did a complete uninstall and reinstall, used the alpha, double-checked everything, and it's still showing up for everyone who is an authorized user. However, if I took the "create classified ads" permission and made it the access argument, it does what I want.
319 'access arguments' => array('create classified ads'),
I really need to learn how to do this module stuff properly. Apologies that these posts have been a bit all over the place.
Comment #6
milesgillham commented!!! I'll have a look at it. Reopening.
Cheers,
Miles
Comment #7
drupup commentedJust checking in to bump this issue back up a bit.
Comment #8
MickC commentedI have this issue too
Comment #9
MickC commented#5 worked for me
Comment #10
fgmIssue also exists in 6.3.
Some sites may want the access check has to be a bit more involved than just checking a permission: a user may have the permission and have created ads, then have the permission removed before his ads were removed. In that case, some sites might allow the user to still have access to the ads he created previously, although the user whould have no right to create new ads.
The permission scheme has more levels now (create, delete any/own, edit any/own, reset). How about these rules ?
This would involve additional settings:
In the meantime, I have added a Simpletest catching that error, so tests won't pass until this is fixed one way or another.
Comment #11
fgmAlso note suggestion by cousin_itt for access control on duplicate issue http://drupal.org/node/959434#comment-4296696
Comment #12
fgmRethought about this question. IMO, the most logical choice is to enable this tab whenever user has the permission to see ads, whether or not there are ads on his account.
If they do not have permission to create ads, it could be a good place to add some text inviting them to gain access to ads creation, like a link to purchase the role giving them access. Seems more useful than just hiding the feature.
Comment #13
alfredlaw commentedI would i like to know how to hide the Ads tab in user account. Since the user is not permitted to post any ads.
I attached a picture of the unwanted tab "Ads"
thanks and regards
Comment #14
fgmI do not think this is a good idea, and will therefore not include it in the module itself. IMO the better idea is to leave that tab available and include some call to action on the target page to gain access to the ads functionality (for example purchase a premium role on the site). For the reasons explained above in this thread, just hiding the tab when a user does not have permission to create ads is not as simple as it may seem.
This said, if you want to do it although the module itself does not follow that logic, you can implement hook_menu_alter() in your module, to modify the menu entry for "user/%user/classified", and change the access callback/access arguments to apply whatever policy you wish, in your case probably somehow like this: