1
xgarb
Hiding blocks for one usergroup
  • 2008/4/15 12:12

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


On my site I have

1) Blocks containing adverts that the anon and registered users have view permissions for.
2) A new group for paid subscribers who should not see adverts.

I know normally you move people into a group with view permissions for blocks that they should see. However in this case moving paid subscibers out of the registered users group causes lots of problems with modules and would be a headache to go through all of them giving access permissions fot the paid subscribers group.

So ideally I would like to keep paid subscribers as part of the registered users group.

Anyone have a clever solution?

I'm thinking of creating a new group maybe called Basic Member and giving view pemission for the ad blocks to that and then adding all registered users to that on signing up but removing them when they buy a subscription.

Or maybe a hack in the theme that skips that numbered block for subscribers.

Could do with a negative block assigning system. So a block can be hidden for a certain user group. Not easy to implement I imagine.

2
xgarb
Re: Hiding blocks for one usergroup
  • 2008/4/18 18:35

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


I've pretty much achieved what I wanted. Possibly not the prettiest way to do this but here's what I did..

I created a new user group and gave it view permission for all the advert blocks. I then removed view permission for those blocks from the registered users group.

Now I need to copy all registered users into the new group so they continue to see ads.

---------

The following SQL

SELECT uid FROM your_db_prefix_groups_users_link WHERE groupid = 2

gives you a table of all registered users

exporting to SQL gives rows like this..

INSERT INTO `your_db_prefix_groups_users_link` VALUES(1);
INSERT INTO `your_db_prefix_groups_users_link` VALUES(5);
INSERT INTO `your_db_prefix_groups_users_link` VALUES(8);
etc.

I copied this into Dreamweaver and did the following find and replace...

find VALUES( replace with (groupid,uid) VALUES (4,

to give

INSERT INTO `your_db_prefix_groups_users_link` (groupid,uid) VALUES (4,1);
INSERT INTO `your_db_prefix_groups_users_link` (groupid,uid) VALUES (4,5);
INSERT INTO `your_db_prefix_groups_users_link` (groupid,uid) VALUES (4,8);
etc.

Importing this to my database adds all registered users to the usergroup id 4 (the basic usergroup that sees ads)

so now all those members are seeing ads again.

-----

Now I need to get all new signups to see the ads as well so in modules/smartprofile/register.php I added the following line..

return _PROFILE_MA_REGISTERNG;
}
 
//line below is my hack to add new user to basic member group
$member_handler->addUserToGroup(4$newid);
if (
$xoopsModuleConfig['activation_type'] == 1) {


around line 188

---------

to remove subscribers from group id 4 (so they don't see adverts) I added the following line to the end of the addUserSubscription in include/functions in the subscription module from Third Eye.

$deletesql "DELETE FROM " XOOPS_DB_PREFIX "_groups_users_link WHERE groupid = 4 AND uid = $uid"// my hack to remove subscriber from basic member group


I've not tested the last part but the rest seems to work ok.

3
xgarb
Re: Hiding blocks for one usergroup
  • 2008/4/20 11:35

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


last part for Third Eye should be this..

---------------------

to remove subscribers from group id 4 (so they don't see adverts) I added the following line to the end of the addUserSubscription in include/functions.php in the subscription module from Third Eye.


$deletesql "DELETE FROM " XOOPS_DB_PREFIX "_groups_users_link WHERE groupid = 4 AND uid = $uid"// my hack to remove subscriber from basic member group
mysql_query($deletesql$db);

Login

Who's Online

168 user(s) are online (94 user(s) are browsing Support Forums)


Members: 0


Guests: 168


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits