The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
5 posters

    How to link to the logged-in user's profile?

    Memento
    Memento
    New Member


    Posts : 4
    Reputation : 1
    Language : English

    Solved How to link to the logged-in user's profile?

    Post by Memento Sat May 26, 2018 1:07 pm

    Technical Details


    Forum version : #phpBB3
    Position : Founder
    Concerned browser(s) : Mozilla Firefox
    Who the problem concerns : All members
    Forum link :

    Description of problem

    So I noticed that the "profile" button on the navigation bar only links to the edit profile section, and that users need to find their own username as a link to view their profile as everyone else does. How do I make a "view profile" button that changes the link depending on who is logged in? So, for User1 when they click the button, it goes to /u1 but if User2 clicks that same button it goes to /u2.


    Last edited by Memento on Mon May 28, 2018 12:20 pm; edited 1 time in total
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: How to link to the logged-in user's profile?

    Post by TheCrow Sat May 26, 2018 1:14 pm

    Hello @Memento,

    You want this link to be in the Navigation bar? Next to the Profile link?



    How to link to the logged-in user's profile? Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Wecoc
    Wecoc
    Forumember


    Male Posts : 144
    Reputation : 111
    Language : Catalan, Spanish, English

    Solved Re: How to link to the logged-in user's profile?

    Post by Wecoc Sat May 26, 2018 2:01 pm

    Side note:

    1) Create the button in the PA, not visible for Guests.
    AP ï…¸ Display ï…¸ Headers and Navigation ï…¸ Add a Customized Menu
    Set the Redirection URL option to /profile

    2) Create a javascript:
    AP ï…¸ Modules ï…¸ Javascript codes management ï…¸ Create a new Javascript

    Code:
    /* Toolbar link to Profile */

    $(function() {
      $('a.mainmenu').filter(function(){
        if (/\/profile$/.test(this.href)){
          this.href = "/u" + _userdata.user_id;
        }
      });
    });

    Title: Toolbar Profile
    Placement: In all the pages

    Make sure Javascript codes are enabled.
    SSYT
    SSYT
    Forumember


    Male Posts : 77
    Reputation : 15
    Language : RO-10, EN-3, FR-1
    Location : Romania

    Solved Re: How to link to the logged-in user's profile?

    Post by SSYT Sat May 26, 2018 4:59 pm

    Hy, use that code for work.
    Code:
    $(function() {
      $('a.mainmenu').filter(function(){
        if (/\/profile\?(.*?)/.test(this.href)){
          this.href = "/u" + _userdata.user_id;
        }
      });
    });
    Wecoc
    Wecoc
    Forumember


    Male Posts : 144
    Reputation : 111
    Language : Catalan, Spanish, English

    Solved Re: How to link to the logged-in user's profile?

    Post by Wecoc Sat May 26, 2018 9:14 pm

    @SSYT That one applies the change on the default Profile (Edit Profile ï…¸ View Profile) button.
    My version requires the creation of another button but then you can have both in the navigation bar Wink
    SSYT
    SSYT
    Forumember


    Male Posts : 77
    Reputation : 15
    Language : RO-10, EN-3, FR-1
    Location : Romania

    Solved Re: How to link to the logged-in user's profile?

    Post by SSYT Sun May 27, 2018 2:53 am

    Oh, try new that:
    Code:
    $(function() {
      $('a.mainmenu').filter(function(){
        if (/\/profile\?(.*?)/.test(this.href)){
          $(this).parent().after('<li><a class="mainmenu" href="/u'+ _userdata.user_id +'"><img id="i_icon_mini_profile" src="https://2img.net/i/fa/empty.gif" border="0" hspace="2" alt="Profile" title="Profile">View Profile</a> &nbsp;</li>'); http://this.href = "/u" + _userdata.user_id;
        }
      });
    });
    Memento
    Memento
    New Member


    Posts : 4
    Reputation : 1
    Language : English

    Solved Re: How to link to the logged-in user's profile?

    Post by Memento Sun May 27, 2018 1:33 pm

    Wecoc wrote:
    Side note:

    1) Create the button in the PA, not visible for Guests.
    AP ï…¸ Display ï…¸ Headers and Navigation ï…¸ Add a Customized Menu
    Set the Redirection URL option to /profile

    2) Create a javascript:
    AP ï…¸ Modules ï…¸ Javascript codes management ï…¸ Create a new Javascript

    Code:
    /* Toolbar link to Profile */

    $(function() {
      $('a.mainmenu').filter(function(){
        if (/\/profile$/.test(this.href)){
          this.href = "/u" + _userdata.user_id;
        }
      });
    });

    Title: Toolbar Profile
    Placement: In all the pages

    Make sure Javascript codes are enabled.

    Thanks, this really helps! I know you can access it from the little Forumotion toolbar but most of my users hide it, so I just wanted to make sure they definitely had access to their profiles outside of the edit field.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: How to link to the logged-in user's profile?

    Post by TheCrow Sun May 27, 2018 1:34 pm

    Did this solve your question/problem?

    If yes, remember you have to mark your topic as Solved once it is actually solved! Wink



    How to link to the logged-in user's profile? Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Ape
    Ape
    Administrator
    Administrator


    Male Posts : 19325
    Reputation : 2005
    Language : fluent in dork / mumbojumbo & English haha

    Solved Re: How to link to the logged-in user's profile?

    Post by Ape Mon May 28, 2018 5:11 pm

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules



    How to link to the logged-in user's profile? Left1212How to link to the logged-in user's profile? Center11How to link to the logged-in user's profile? Right112
    How to link to the logged-in user's profile? Ape_b110
    How to link to the logged-in user's profile? Ape1010

      Current date/time is Sun Sep 22, 2024 10:27 pm