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

Go down

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

Post by Memento on May 26th 2018, 8: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 May 28th 2018, 7:20 pm; edited 1 time in total
Memento
Memento
New Member

Posts : 4
Reputation : 1
Language : English

http://chaoticneutral.forumotion.com/

Back to top Go down

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

Post by TheCrow on May 26th 2018, 8:14 pm

Hello @Memento,

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

Male Posts : 5955
Reputation : 672
Language : Greek, English
Location : Cyprus, Greece

https://www.inforumgr.com

Back to top Go down

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

Post by Wecoc on May 26th 2018, 9:01 pm

Side note:
Just to make sure you are aware of it, since your forum uses a toolbar, users can easily access their profile from there.
Toolbar Welcome (Name) View profile
So maybe you don't need to do anything else.

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.
Wecoc
Wecoc
Forumember

Male Posts : 136
Reputation : 100
Language : Catalan, Spanish, English

http://www.mundo-maker.com/

Back to top Go down

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

Post by SSYT on May 26th 2018, 11: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;
    }
  });
});
SSYT
SSYT
Forumember

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

http://help.forumgratuit.ro/forum

Back to top Go down

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

Post by Wecoc on May 27th 2018, 4:14 am

@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
Wecoc
Wecoc
Forumember

Male Posts : 136
Reputation : 100
Language : Catalan, Spanish, English

http://www.mundo-maker.com/

Back to top Go down

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

Post by SSYT on May 27th 2018, 9: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://illiweb.com/fa/empty.gif" border="0" hspace="2" alt="Profile" title="Profile">View Profile</a> &nbsp;</li>'); http://this.href = "/u" + _userdata.user_id;
    }
  });
});
SSYT
SSYT
Forumember

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

http://help.forumgratuit.ro/forum

Back to top Go down

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

Post by Memento on May 27th 2018, 8:33 pm

@Wecoc wrote:
Side note:
Just to make sure you are aware of it, since your forum uses a toolbar, users can easily access their profile from there.
Toolbar Welcome (Name) View profile
So maybe you don't need to do anything else.

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.
Memento
Memento
New Member

Posts : 4
Reputation : 1
Language : English

http://chaoticneutral.forumotion.com/

Back to top Go down

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

Post by TheCrow on May 27th 2018, 8: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
TheCrow
TheCrow
Manager
Manager

Male Posts : 5955
Reputation : 672
Language : Greek, English
Location : Cyprus, Greece

https://www.inforumgr.com

Back to top Go down

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

Post by APE on May 29th 2018, 12:11 am

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



APE
APE
Administrator
Administrator

Male Posts : 13842
Reputation : 1473
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum