Compare current member with member id in textstring
Hi guys,
Via Doc2Form i am able to have my members add new pages. When a member adds a new page, i store their member ID in a textstring on the node.
Now i want to have the members edit these pages again, and thats quite easy - but what it i want ONLY the user who ADDED the page, to be able to EDIT the page again? (all other users should just be able to read the page!)
Can you somehow compare the member id that's stored in the nodes, with the current logged in member's id? (code sample, please :o) )
Or are there other methods, for letting the only one user (= the creator) edit a page?
which will return info about the member currently logged on. I don't know what xml fragment will be returned exactly from the method, but you can simply find that out by embedding that xml in a textarea html field as in
Thanks for your help. I have found that snippet before, but never really knew what to do with it. But now I manage to do what i wanted.
Thanks a bunch!
If anyone else ever come across this, my final code went like this:
<xsl:for-each select="$currentPage/self::node">
<!-- TEST TO MAKE SURE THERE IS AN ID IN 'MEMBERID' TEXTSTRING - OTHERWISE THE XSLT SHOWS AN ERROR -->
<xsl:if test="string(data[@alias = 'memberId']) != ''">
<!-- GO DOWN THE TREE TO FIND THE DATA IN THE MEMBERID TEXTSTRING -->
<xsl:variable name="memberID" select="$currentPage/data [@alias = 'memberId']"/>
<!-- HOLD THE DATA FOUND IN THE TREE ABOVE -->
<xsl:variable name="member" select="umbraco.library:GetMember($memberID)" />
<!-- SHOW THE EXACT DATA WE WANT, E.G. HERE THE NODENAME -->
Written by: <xsl:value-of select="$member/@nodeName" /><br />
<!-- GET THE CURRENT LOGGED IN MEMBER DETAILS AND STORE IT -->
<xsl:variable name="currentmember" select="umbraco.library:GetCurrentMember()"/>
<!-- DISPLAY CURRENT LOGGED IN MEMBER NODENAM -->
Current bruger: <xsl:value-of select="$currentmember/@nodeName" />
<!-- LET MEMBER EDIT PAGE IF CURRENT MEMBER IS THE SAME AS THE CREATOR OF THE PAGE -->
<xsl:if test="$currentmember/@id = $member/@id">
<a href="?alttemplate=TestRestrictedEdit">Let Albert Edit</a>
</xsl:if>
</xsl:if>
</xsl:for-each>
Compare current member with member id in textstring
Hi guys,
Via Doc2Form i am able to have my members add new pages. When a member adds a new page, i store their member ID in a textstring on the node.
Now i want to have the members edit these pages again, and thats quite easy - but what it i want ONLY the user who ADDED the page, to be able to EDIT the page again? (all other users should just be able to read the page!)
Can you somehow compare the member id that's stored in the nodes, with the current logged in member's id? (code sample, please :o) )
Or are there other methods, for letting the only one user (= the creator) edit a page?
Hope someone has a bright idea.
cheers/
Hundebol
Hundebol,
From xslt, you can use
which will return info about the member currently logged on. I don't know what xml fragment will be returned exactly from the method, but you can simply find that out by embedding that xml in a textarea html field as in
Just need to know how to query for the id of the member using an xpath query and you're set.
hope this helps.
Regards,
/Dirk
Hi Dirk,
Thanks for your help. I have found that snippet before, but never really knew what to do with it. But now I manage to do what i wanted.
Thanks a bunch!
If anyone else ever come across this, my final code went like this:
best regards, Hundebol
is working on a reply...