This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.
Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.
Before posting questions here you might want to review the developer documentation.
Hi,
I'm developing a project tracking module.
I'd need to get the UserID of the table mp_Users when a user is loged in.
Is the UserID(which is an integer) already included in the class SiteUser.cs?
Can we obtain UserID from the cache(when user is loged in)?
Thanks
Thanh
Hi Joe,
How can I find the UserId in a module I've written for a recent SVN? I've based my module on your EmptyModule and have tried the revisions to SiteUser.cs mentioned above; but I get compile errors.
Perhaps you have taken a different path since you wrote this note, Dale E. Moore
Hi Dale,
using mojoPortal.Web;
using mojoPortal.Business;
SiteUser currentUser = SiteUtils.GetCurrentUser();
now you have an instance of the user and can get the integer id with .UserID or the Guid id with .UserGuid
Hope it helps,
Joe
GetCurrentUser() didn't exist. So I updated the SVN and now I get "Microsoft Visual Studio Unable to read the project file 'mojoPortal.Web.csproj'. mojoPortal\Web\mojoPortal.Web.csproj(7088,2); The project file could not be loaded. Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 7088, position 2. OK Cancel". I found this at 7087-7090:
<Folder Include="Data\Sites\1\flash\" /> <<<<<<< .mine ======= <Folder Include="Data\Sites\1\GalleryImages\EditorUploadImages\"
So I pulled 7088-9 and (wait for it)...
Unable to read 7092,45; The element <#text> beneath element <ItemGroup> is unrecognized.
7092-4: <Folder Include="Data\Sites\1\index\" /> >>>>>>> .r2363 <Folder Include="Data\Sites\1\SharedFiles\History\" />
And it builds, but I still get:
Error 3 'mojoPortal.Web.SiteUtils' does not contain a definition for 'GetCurrentUser' D:\webs\MW\src\mojoPortal\Web\Modules\TechModule.ascx.cs 85 46 mojoPortal.Web
But I did find GetCurrentSiteUser SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
Now I get "A project with an Output Type of Class Library cannot be started directly" when I build the solution. But when I set mojoPortal.Web as the startup project, things go swimingly.
Errr the site debugs but the user is not "DaleEMoore" whom logged on, but instead "mojoPortal.Business.SiteUser".
Still scratching my head, Dale E. Moore
My bad, I was typing from memory the method is SiteUtils.GetCurrentSiteUser(); as you found it.
if you want the name of the user its .Name, Email is .Email and so on for any user property.
or if all you need is the name then you can also use HttpContext.Current.User.Identity.Name
This works PERFECTLY, thanks!
How didi you lose your ID?
Hi Trading,
Well truth be told, I never had it to begin with so it wasn't really lost like I didn't loose my last girlfriend; I just came home and she wasn't there.
Good luck, Dale E. Moore