Add link to profile from Display Name in members list?

Hi there,

I’ve searched the forum but can’t find anything for this - I’d like to set a link for each member’s display name in my list of members, to their individual profiles on my profile page.

I’ve seen that I can copy and edit the member-list.php (see https://s2member.com/kb-article/using-a-custom-template-for-s2member-list/ ) and save it in my child theme.

I’ve found the area I need to edit within this file, but can’t find any ‘empty values’ in it as described here: “link_display_name Optional, defaults to “” (an empty string; i.e., no link)” as instructed in this article: https://s2member.com/kb-article/s2member-list-shortcode-documentation/.

So I’m not quite sure where to add my link in for this. The code segment I have is this:

							<?php if($attr['show_display_name'] && $_user->display_name): ?>
								
<?php if(($_display_name_link = c_ws_plugin__s2member_pro_sc_member_list_in::parse_link_replacement_codes($attr['link_display_name'], $_user))): ?> ><?php echo esc_html($_user->display_name); ?> <?php else: echo esc_html($_user->display_name); endif; ?>
<?php endif; ?>

Can anyone help me with this?
Many thanks,
j

@hubcontrol: Jenny, I haven’t actually tried this, but I think what you need to do is to modify the shortcode rather than the template.

So I think what you need is something like this:

[s2Member-List link_display_name="/members/%%nicename%%/" /]

@KTS915 - thanks for your suggestion.

I’ve fiddled around with it, but no matter which option I use (like %ID%%, %%username%%, %%nicename%%, or %%display_name%%) it just returns a 404 page - the url is correct for my profile page, but it can’t locate the bit after that. ie: my-site.com/profile-page/123/ - for %ID%%.
And if I leave it off, it links to the profile page but for my profile of course!

I had tried some of these originally (but without the correct url in front of them I see now) but with no luck.

I’ve also removed Buddypress, which is why I’m trying to create a simple members list - do you think these shortcodes are dependant on having Buddypress?

Any other thoughts?

many thanks, j

No, only the one I gave you!

Let’s take your example of my-site.com/profile-page/123/

Is that the actual URL for the page?

If not, that’s why you get a 404 when you simply add %ID%%. If it is the real URL, then try re-saving permalinks and make sure that you have all caching turned off.

@KTS915 Thanks for your suggestions… and I’m gradually understanding it a bit better now.

The actual url to my profile page is my-site.com/profile-page/
I’ve checked it when I’m signed in as an admin, and as a test member and it’s the same: my-site.com/profile-page/ without anything after it for different users/members.

Great idea to re-save the permalinks! ( I always forget this simple option) and deactivate my caching plugin - that stopped the 404 page, BUT no matter which member’s name I click on it shows my profile, even though the member’s ID was now in the url and it was different for each one I selected.

ie: I clicked on John Smith and it went to my-site.com/profile-page/123/ = but MY profile
and when I clicked on Mary Jane it went to my-site.com/profile-page/456/ = but still MY profile!!!

So getting there, but not quite right yet…

OK, progress, but I’m still not sure whether you’re saying that my-site.com/profile-page/123/ is an actual URL. In other words, what is the actual URL for the profile page for John Smith?

Hi again, sorry for the delay as got held up with work commitments.

So… when I sign in as ‘me, the admin person’ and then go to my profile the url for my profile is just my-site.com/profile-page/
and when I sign in as my test user/member ‘Jo Bloggs’ and then go to my/Jo Bloggs’s profile page it’s still my-site.com/profile-page/ - so no ID in the url, or anything else.

In the scenario I mentioned previously, I think it was was adding the member’s ID number to the url as that was what I had in the shortcode to try to link to each individual member’s profile, instead of my own: [s2Member-List link_display_name="/profile/%%ID%%/" /]

But as I said it added the ID number to the url but still showed the profile of the member that I was logged in as.

So a bit stumped here… any ideas where I’m going wrong? as this certainly seems the logical way to do it!

It sounds like you haven’t actually created the page to where the member is supposed to go. That’s why the redirection isn’t working; there’s nowhere to redirect to.

Not sure I understand…
I created a ‘profile’ page and then from the s2m pro General Options instructions “Shortcode (copy/paste), for an Inline Profile Modification Form:” I added the shortcode [s2Member-Profile /] into this page.

But I think see what you’re saying, that by just using this shortcode in my profile page it will ONLY show the profile of the logged in user - is that right?

If so, how to I designate a page to show other members’ profiles? via their ID or display name or whatever?

Yes.

But, in addition, you can’t just add stuff to the end of a URL and expect it to work. That URL has to actually exist on the site. So if you just want to redirect to the page where this shortcode is, just use the URL for that page, and don’t add anything else.

OK, sorry to be a bit slow here, but how do I find the url for other members profile page? when they will all be adding their profile into the same page, ie: my-site.com/profile-page/.

If I look at my current live site, which still has BuddyPress installed and active, then my profile page (for me when logged in admin user) is:my-site.com/member/admin/ and when I click on the link to another member ‘John Smith’ it goes to their profile at: my-site.com/member/johns/. But I haven’t generated these different ‘pages’, as they’re generated by Buddypress dependant on the members username.

But s2member says it doesn’t need BuddyPress to work and to manage a small online community.

@hubcontrol The reason for all the confusion in this thread is that [s2Member-Profile /] is not designed to generate a profile for any member—it’s designed to generate a Profile Editing Form for the currently logged-in user. So if you want to create a button on the site that allows logged-in users to edit their profile, you can link them to a page that contains the [s2Member-Profile /] shortcode, which will display a form that allows them to edit their profile.

What you’re trying to do is make it possible for any user to click the name of any other user on a list generated by the [s2Member-List /] shortcode and have that link go to a page that shows that member’s profile. s2Member does not have any shortcode or any way of displaying information about another member, as everything in s2Member was designed around the intention of members accessing content that was restricted by the site owner. It’s not designed as a community-based plugin (like BuddyPress) where members are expected to interact.

The [s2Member-List /] shortcode is designed to allow you to generate a list of members on your site, but that’s the extent of its intention. If you want to extend the shortcode to do other things, such as linking each member in the list to another page, the shortcode provides that flexibility (as @KTS915 mentioned with the link_display_name="" attribute). However, whatever you link to must already exist.

s2Member does not automatically generate public profile pages for each member that you could link to (the way BuddyPress does), so if you wanted to make it possible for members to click names in the list generated by [s2Member-List /], you’ll need to find a way to dynamically generate the profile pages for each member. Again, BuddyPress has that functionality built-in, as that’s what that plugin is designed for.

I hope this clarifies things a bit.

Hi, thanks for your detailed explanation.

I guess I was getting confused, as I’m sure I’d read somewhere that s2member could act like a mini community without the need for Buddypress. But I now realise it can’t, other than a list of members - pity.

So my final Q (in desperation of trying to get it to do what I want it to do :slight_smile:) is:
If I copy and edit the template member-list.php, and add it to my child theme,and then reference it in the profile shortcode, as per the articles in my initial post… will that achieve what I’m trying to do?

Thanks.

If you’re trying to get a link attached to each member’s name in the list generated by the [s2Member-List /] shortcode, then you should just use the link_display_name="" that @KTS915 mentioned above.

If you’re trying to generate a public profile for each member, then modifying member-list.php or the [s2Member-List /] won’t really help you, as that shortcode simply generates a list of users—it doesn’t generate public profiles. (I suppose you could modify it to also generate public profiles, but that seems like the wrong place to do that — it would be better to keep that code separate from the [s2Member-List /] shortcode and simply link to the page where the profiles are generated).

@raamdev Thanks for your help again.

I now understand what the s2m list will and won’t do, so will need to look at it from another perspective to achieve what I want on our site.

I think I’ll just use the really simple show_fields option for within the [s2Member-List /] to provide a short member profile all in one place instead.

And many thanks to you and @KTS915 for your help in helping me to understand how it functions. Sorry if it was a bit of a struggle at times!