Form Helper: limit access to super admins or specific group? 
Posted: 25 April 2008 11:02 AM   [ Ignore ]
Jr. Member
RankRank
Total Posts:  46
Joined  2007-09-10

Hello,

I see in the documentation for Form Helper that you can easily limit it’s use to the author who wrote the entry. But, can you limit it’s use to certain membergroups? Surely it allows Super Admin access.... somehow. Currently, I am using the

{exp:form_helper:member_is_author author_id="{author_id}"}
{if member_not_author}
Sorry
. Only the author of this entry is allowed to edit it.
{/if}
{exp
:weblog:entry_form weblog="weblog1"} blah blah blah {/exp:weblog:entry_form}
{
/exp:form_helper:member_is_author}

From the docs, and If I (as the super admin) am not the author, I am not allowed to edit the entry.

There has got to be a away to allow the superadmin plus the author to edit the entry. Right?

Profile
 
 
Posted: 25 April 2008 11:25 AM   [ Ignore ]   [ # 1 ]
Jr. Member
RankRank
Total Posts:  46
Joined  2007-09-10

Um… This is how it works (so simple. Gotta love EE)

{if group_id == '7' OR '1'}(<a href="{path="{my_weblog}/edit_entry/{entry_id}"}">Edit Entry &raquo;</a>){/if}

Profile
 
 
Posted: 25 April 2008 11:43 AM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2232
Joined  2006-10-18

Evoir…

Yes, that easy! LOL

Though, I would recommend you use the “logged_in” part to the conditional:

{if logged_in_group_id == '7' OR '1'}(<a href="{path="{my_weblog}/edit_entry/{entry_id}"}">Edit Entry &raquo;</a>){/if}

For example, if you place an Edit shortcut link in a weblog:entries loop as {if group_id...}, what you’re telling EE is that IF the GROUP ID of the AUTHOR is “7” or “1”, display the link. Hence, if you post the entry as Admin, the link will show for ALL. If you use the {if logged_in_group_id...} you’re specifying IF the GROUP ID of the LOGGED IN MEMBER is “7” or “1”, display the link.

smile

 Signature 
Profile
 
 
Posted: 25 April 2008 11:58 AM   [ Ignore ]   [ # 3 ]
Jr. Member
RankRank
Total Posts:  46
Joined  2007-09-10

Pie Man, thank you! Now, oddly, I am finding that the following

{if logged_in_group_id == '7' OR '1'}(<a href="{path="{my_weblog}/edit_entry/{entry_id}"}">Edit Entry &raquo;</a>){/if}

does not restrict access to that link.... I don’t know why. How I am testing is that I am logged in as a superadmin using Firefox, and in Safari I am not logged in and I still see the link to edit. I’m certain I am doing something stupid....

Profile
 
 
Posted: 25 April 2008 12:03 PM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2232
Joined  2006-10-18

Can you PM me a link… I’ll see if I see a link LOL

 Signature 
Profile
 
 
Posted: 25 April 2008 12:06 PM   [ Ignore ]   [ # 5 ]
Jr. Member
RankRank
Total Posts:  46
Joined  2007-09-10

just sent you a link

Profile
 
 
Posted: 25 April 2008 12:11 PM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2232
Joined  2006-10-18

Hmmm, I see it too…

Try this variation instead: smile

{if logged_in_group_id == "1" || logged_in_group_id == "7"}

 Signature 
Profile
 
 
Posted: 25 April 2008 12:13 PM   [ Ignore ]   [ # 7 ]
Jr. Member
RankRank
Total Posts:  46
Joined  2007-09-10

That worked. smile Did it work for you, too?

Thank you!

Profile
 
 
Posted: 25 April 2008 01:30 PM   [ Ignore ]   [ # 8 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2232
Joined  2006-10-18

Indeed smile

 Signature 
Profile
 
 
Posted: 25 April 2008 02:54 PM   [ Ignore ]   [ # 9 ]
Jr. Member
RankRank
Total Posts:  46
Joined  2007-09-10

You know what, this did not work completely.... it only allowed the first one (group_id 1) in, but 7 could not see the edit link. :(

This is what I used: {if logged_in_group_id == “1” || logged_in_group_id == “7"}

Profile
 
 
Posted: 26 April 2008 08:31 AM   [ Ignore ]   [ # 10 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2232
Joined  2006-10-18

Evoir,

It’s the code I use all the time for this type of thing… though I am curious…
Which template level do you have this code on? The home page?

 Signature 
Profile
 
 
Posted: 27 April 2008 02:03 AM   [ Ignore ]   [ # 11 ]
Jr. Member
RankRank
Total Posts:  46
Joined  2007-09-10

ok Pie Man, it was user error. I was using the wrong member group number rasberry oops. Thanks for the great support. smile

Profile
 
 
Posted: 28 April 2008 06:20 AM   [ Ignore ]   [ # 12 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  2232
Joined  2006-10-18

hehe.... you’re welcome LOL

 Signature 
Profile