Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marky 26 posts 65 karma points
    Oct 01, 2018 @ 07:39
    Marky
    0

    How to detect Member if it his/her first time visited the page?

    Hi All,

    I want to detect this member who is it's first time visited the page for my Take A Tour function.

    Can anyone give some ideas.

    Thanks

    Marky

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Oct 01, 2018 @ 08:10
    Paul Seal
    0

    Hi Marky What about using a cookie?

    Kind regards

    Paul

  • Marky 26 posts 65 karma points
    Oct 01, 2018 @ 08:18
    Marky
    0

    Hi Paul,

    Do you have a sample code for my reference.

    Thanks

    Marky

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Oct 01, 2018 @ 09:26
  • Steve Morgan 1348 posts 4457 karma points c-trib
    Oct 01, 2018 @ 10:29
    Steve Morgan
    0

    Paul's right - a cookie would work fine though if you don't want to bug the member if they use a different computer / device then you might want to store this against their member record in Umbraco. If so create a variable and use the MemberService to update this flag.

    https://24days.in/umbraco-cms/2014/dealing-with-members/

    Remember after changing a value you have to save the member!

    Steve

  • Marky 26 posts 65 karma points
    Oct 02, 2018 @ 03:01
    Marky
    0

    Hi Steve,

    Thanks for your ideas!

    It might be need to get the MemberId to check if this Id already visited the page?

    Thanks,

    Marky

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Oct 02, 2018 @ 07:12
    Steve Morgan
    0

    This would only be sensible for logged in members. But yes,

    var umbMember = Membership.GetUser();
    var _memberService = ApplicationContext.Current.Services.MemberService;
    var umbMemberProfile = _memberService.GetByUsername(umbMember.UserName);
    
    
    umbMemberProfile.SetValue("takenTour", true);
     _memberService.Save(umbMemberProfile);
    
  • Marky 26 posts 65 karma points
    Oct 02, 2018 @ 09:16
    Marky
    0

    Hi Steve,

    Sorry, I'm new in Umbraco coding.

    As what I've understand in your given code, is only putting a value in takenTour upon registration.

    I think the idea is, after member registered the takenTour value is sets to False and when it's visited the page, it will set to True.

    Can you help me, on how to put this in the specific page?

    Thanks,

    Marky

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Oct 02, 2018 @ 10:31
    Steve Morgan
    0

    Hi,

    Hard to say where to put it - how far have you got? Do you have a member's registration and login page?

    Step through my three tutorials and the penny should drop.

    http://siempresolutions.co.uk/blog/UmbracoMembersProtectedAreaof_Website

    http://siempresolutions.co.uk/blog/UmbracoMembersProtectedAreaofWebsitePart2UsingMVCMembersController

    http://siempresolutions.co.uk/blog/UmbracoMembersPart3AFullSolution

    The code's a little old now and I want to update the redirect stuff but the principles are all there.

    Steve

  • Marky 26 posts 65 karma points
    Oct 03, 2018 @ 06:35
    Marky
    0

    Hi Steve,

    I've done it using your code, thanks.

    But is this code will not bug in the future?

    if (Request.IsAuthenticated)
    {
        var umbMember = Membership.GetUser();
        var _memberService = ApplicationContext.Current.Services.MemberService;
        var memberId = _memberService.GetByProviderKey(umbMember.ProviderUserKey);
    
        var umbMemberId = Umbraco.TypedMember(umbMember.ProviderUserKey);
        var TakeATour = umbMemberId.GetPropertyValue<bool>("takeATour");
    
        if(!TakeATour)
        {
            memberId.SetValue("takeATour", true);
            _memberService.Save(memberId);
            //put takeatour.js
        }
    }
    

    Thanks you mate,

    Cheers,

    Marky

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Oct 03, 2018 @ 15:46
    Steve Morgan
    0

    Sorry - I don't follow you - what you do mean by "But is this code will not bug in the future?"

    Steve

Please Sign in or register to post replies

Write your reply to:

Draft