Is there a way to set member permissions so that certain content gets displayed to one member group and the same content plus more (a sidebar widget) gets displayed to another member group?
When members log in, they all see nearly the same content on the member home page. And I have a calendar page that can be seen by only one member group. That's set up. But I'd like for that member group to also see a link to the calendar page when they log in.
When I restricted the sidebar widget to only that group, it showed up anyway for the other group.
I don't think you are going to be able to do this without using some kind of code, be it either xslt or razor. Is there a reason you don't want to use code either in a macro or a template to do this? It would be a pretty trivial bit of macro code to achieve the result you want.
How are you writing the link in the first place? Is this not output by a navigation macro anyway? In which case you could easily add your logic in there. If you post how you are getting your link onto the page I can send you the necessary code
Thanks Richard! Yes, I meant avoiding recompiling but an xslt solution would be perfect. Currentlythe link is just a static link added to the sidebar. But I do have a navigation macro. How do I post that? I have no attachment icon in the wysiwyg, and of course the xslt couldn't be pasted.
Here is some XSLT code that you should be able to incorperate into your navigation. I have implemented a C# method in there to check if the current user is in a particular role "Allowed" in this case. Then I call this fuction from an if statement and either show a link or not depending on whether the user is in the role or not.
There is a way to do this....Try following helpers......
@Membership.GetUser() -- to get member name@Members.GetCurrentMemberId() -- to get member id@Roles.IsUserInRole("Group_Name") -- to know whether member is of this group or not
Member permissions per content area on page
Is there a way to set member permissions so that certain content gets displayed to one member group and the same content plus more (a sidebar widget) gets displayed to another member group?
When members log in, they all see nearly the same content on the member home page. And I have a calendar page that can be seen by only one member group. That's set up. But I'd like for that member group to also see a link to the calendar page when they log in.
When I restricted the sidebar widget to only that group, it showed up anyway for the other group.
Is there a non-programmatic way to do this?
(Sorry I'm adding a comment and not editing; I'm getting an xslt error message when trying to edit.)
I guess it comes down to:
Is there a way to show/hide a link based on membership group?
Hi Shmuel,
I don't think you are going to be able to do this without using some kind of code, be it either xslt or razor. Is there a reason you don't want to use code either in a macro or a template to do this? It would be a pretty trivial bit of macro code to achieve the result you want.
How are you writing the link in the first place? Is this not output by a navigation macro anyway? In which case you could easily add your logic in there. If you post how you are getting your link onto the page I can send you the necessary code
cheers
Thanks Richard! Yes, I meant avoiding recompiling but an xslt solution would be perfect. Currentlythe link is just a static link added to the sidebar. But I do have a navigation macro. How do I post that? I have no attachment icon in the wysiwyg, and of course the xslt couldn't be pasted.
Hi Shmuel,
Here is some XSLT code that you should be able to incorperate into your navigation. I have implemented a C# method in there to check if the current user is in a particular role "Allowed" in this case. Then I call this fuction from an if statement and either show a link or not depending on whether the user is in the role or not.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:google.maps="urn:google.maps" xmlns:consea="urn:consea"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets google.maps consea
">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<msxml:script implements-prefix="consea" language="C#">
<msxml:assembly name="System.Web"/>
<msxml:using namespace="System.Web.Security"/>
<![CDATA[
public bool UserIsInRole(string group)
{
if(Roles.IsUserInRole(group))
{
return true;
}
return false;
}
]]>
</msxml:script>
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:if test="consea:UserIsInRole('Allowed')">
<a href="#">Your Link</a>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
I hope this works for you.
cheers
There is a way to do this....Try following helpers......
@Membership.GetUser() -- to get member name @Members.GetCurrentMemberId() -- to get member id @Roles.IsUserInRole("Group_Name") -- to know whether member is of this group or not
I think it will work.
is working on a reply...