Hello,
I am using XMP for the main login. Now my site has two rolegroups:
Employers
and
Employees
When a user logs in, I'd like to base the redirect page on the user's rolegroup. I've been trying a lot of things with the redirect tag as such:
<redirect if='RoleNames=Employees' target="~/employees" method="Get" />
But I can't get it to work.
Could someone please explain how to do this (if it is at all possible..) ?
Thanks
(reposted here from discuss forum)
Continued (have followed up on Patrick's instructions):
Hi Patrick,
thanks for the help
I have been struggling to make this work and got nowhere. Maybe I am doing something silly.
Perhaps you can point me in the right direction?
Here is my proc. This checks the DNN database to see if the user has the Employers role.
DROP PROCEDURE dbo.q_IsUserEmployer
GO
CREATE PROCEDURE dbo.q_IsUserEmployer
@UserName NVARCHAR(100),
@IsUserEmployer int OUTPUT
AS
SELECT @IsUserEmployer = CAST(ur.roleID AS int) FROM userRoles ur
INNER JOIN users u ON u.UserID=ur.UserID
INNER JOIN Roles r ON r.RoleID=ur.RoleID
AND r.RoleName='Employers'
WHERE u.Username=@UserName
--PRINT @IsUserEmployer
GO
-- Tests
-- Employee
EXEC dbo.q_IsUserEmployer @UserName = N'[email protected]',
@IsUserEmployer = '0'
-- Employer
EXEC dbo.q_IsUserEmployer @UserName = N'[email protected]',
@IsUserEmployer = '0'
The proc returns the output param which I am trying to use in the form.
In my form I have the following submitcommand
<SubmitCommand CommandText="q_IsUserEmployer" CommandType="StoredProcedure">
<Parameter Name="UserName" value='[[Uname]]' DataType="string" />
<Parameter Name="IsUserEmployer" Direction="Output" DataType="int32" />
</SubmitCommand>
After my <login> section I have this:
<Redirect If='[[IsUserEmployer]] = 1' Target='/test1?p=[[IsUserEmployer]]' />
<Redirect If='[[IsUserEmployer]] = 0' Target='/test2?p=[[IsUserEmployer]]' />
But the output parameter is always empty.
I've also tried reading the parameter as per the doc:
<AddSuccessTemplate>
This is my return value: [[retVal]] <br />
<xmod:Redirect Display="Button" Text="View New Record" Target="href://mysite.com/TeamDetail.aspx" Method="Post">
<Field Name="teamid" Value='[[newID]]' />
</xmod:Redirect>
</AddSuccessTemplate>
(NOTE: the doc has an error there should be an item template in the success template otherwise it blows)
If I add the parameter like that in the success template I get the given key was not present in the dictionary.
I've tried using a string for the output parameter.