Hey guys,
I have just written a quick plugin that restricts templates to members with a specific id or that belong to a specific group.
I know you can restrict template groups but I also needed to restrict templates from certain members.
So I present LG Access (restrict to)…
Place the plugin code at the top of your template like so:
{exp:lg_access:restrict_to
member_id = "1"
redirect_to = "/members/login/access-denied"
}
and if the current member is not member 1 then they will be redirected to the redirect_to url.
The plugin also accepts member groups
{exp:lg_access:restrict_to
group_id = "2"
redirect_to = "/members/login/access-denied"
}
or multiple members delimited by a pipe
{exp:lg_access:restrict_to
member_id = "1|2"
redirect_to = "/members/login/access-denied"
}
or multiple member groupss delimited by a pipe
{exp:lg_access:restrict_to
group_id = "1|2"
redirect_to = "/members/login/access-denied"
}
I was planning to add a return_to param so once a user is logged in then they would be returned to the same page they where restricted from but that would involve session madness, unless someone else has a better idea?
The initial idea for this plugin came from comments in Mark Bowens Redirect Plugin which is much more flexible when it comes to standard redirects.
You must have read my mind with this one. I actually created a plugin to do exactly this and was going to release it!!
I made it pretty much around the same time as the Redirect Plugin as I needed this functionality for a site. Mine was literally cobbled together so I’m going to take a look at yours as I know your code will probably be a lot neater! 😉
Best wishes,
Mark
Not really. Mine works but yours has a little more functionality so it wouldn’t really be so much of a merge than a down-grade for yours!! 😊
I do think that you need to check some of your comments and such in the code though as it appears that you have some of your Latest EE version code names in there 😉
Best wishes,
Mark
Not really. Mine works but yours has a little more functionality so it wouldn’t really be so much of a merge than a down-grade for yours!! 😊 I do think that you need to check some of your comments and such in the code though as it appears that you have some of your Latest EE version code names in there 😉 Best wishes, Mark
Yeah thats the beta, beta, first attempt part 😊 I’ll clean up the code and add some documentation to my site if you think this plugin will be useful.
Ok documentation is up!
Grab the LG Access (Restrict To) plugin from my site.
I added some blacklist/whitelist + banned member group checking as well for good measure.
Cheers Leevi
@Mark: There is some code in the plugin or handling URLs that you might find useful for your redirect plugin 😉
I know I know!! My coding is not the best. Was meaning to try and use the create url function. I did originally try it but for some reason couldn’t get it to work properly under every condition. Will probably take a look at it when I get a bit more time.
Well done on getting this up on your site with documentation so quickly. You really are a fantastic asset to the EE community!
Best wishes,
Mark
Leevi, my question to you is how do you accomplish making these things so quickly? You must have a fantastic grasp of how EE works. Thanks for all your stuff.
I have a pretty nice library of functions I can call on these days and my knowledge has increased over the last few months.
This one was actually needed for a client project so that always helps. I’m guessing the learning will have to start again in the next few weeks with EE 2.0 on the way :(
This one was actually needed for a client project so that always helps.
Mine too. Sometimes you just get pushed into having to figure out how to do something so that you can get a site working for a client 😊
I’m guessing the learning will have to start again in the next few weeks with EE 2.0 on the way :(
Please don’t remind me!! 😉
Can’t wait to see what goodies the EE crew have up their sleeves though!! 😊
Best wishes,
Mark
Any reason you can see for this error?
Notice: Undefined variable: IN in /usr/www/users/poc/mysite.com/system/plugins/pi.lg_access.php on line 89
Notice: Trying to get property of non-object in /usr/www/users/poc/mysite.com/system/plugins/pi.lg_access.php on line 89
Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/poc/mysite.com/system/plugins/pi.lg_access.php:89) in /usr/www/users/poc/mysite.com/system/core/core.functions.php on line 296
Any reason you can see for this error?Notice: Undefined variable: IN in /usr/www/users/poc/mysite.com/system/plugins/pi.lg_access.php on line 89 Notice: Trying to get property of non-object in /usr/www/users/poc/mysite.com/system/plugins/pi.lg_access.php on line 89 Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/poc/mysite.com/system/plugins/pi.lg_access.php:89) in /usr/www/users/poc/mysite.com/system/core/core.functions.php on line 296
Yeah I’m guessing a global is not defined for the method… I’ll take a quick look at it now..
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.