Skip Navigation

[Resolved] Creating and linking to a user profile page

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by Simon Logan 4 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1539403

On our site just now we have users registered and these users can add finance products to the site which other users can then filter/search on.

In the result listings it displays some info from a custom post type (finance product) as well as some info for the user who added its WP profile (at present their image/logo). What we'd like is to link that logo to a profile page which would display info from their user profile (custom fields and/or built in ones) as well as a listing beneath this which shows all products they currently have on the site.

I'm not clear on the best way to achieve this, can you provide guidance?

#1539481

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simon,

Thank you for getting in touch.

For clarity you essentially want to add the information of the user who created the post and then link this to their profile page correct?

Please let me know and we can go from there.

Thanks,
Shane

#1539547

Hi Shane

We already include their info in the view's loop (at least their logo image which comes from the "User Logo" WordPress profile field) and yeah what we'd like to do is to link this to a profile page. So someone clicks on that logo and it takes them to a page which displays their name and logo in the header then beneath this a view which lists all posts created by this user.

The bit I'm not sure about is that I presume I need to pass a variable to the profile page to identify which user's details we should be showing but also I'm not 100% clear on what approach I should take to create this profile page in the first place? We are using Elementor Pro so could i create a page then embed a view in the header which has their profile info and another view beneath which lists their products, then use a URL param or similar so that the page knows which profile to show? So the URL would be something like mysite.com/lenderprofile&pid=23 where 23 is the userID, then the views would look for and filter by this param?

Or is there another better approach to take?

#1539625

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simon,

Ok so in this case all you need todo is wrap the item that you want to be clickable in an anchor tag.

<a href='myurltopage?pid=25'>Item that should be clickable</a>

This should allow you to enable the item to be clickable for you to click to the person's profile.

Thanks,
Shane

#1539761

Thanks for confirming, that’s the more straightforward bit, what I was really looking for guidance on was how to create that profile page in the first place. Is the approach I suggested the best method?

#1540773

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simon,

Sure, all you need to do is create a page with a user view on it.

On that view you will select the roles that the user will fall under. Then add a query filter to that view for the user id. Set that filter to get the user id from the URL parameter.

Then customize your view with the items that you want to display for that user.

Finally just link to that page from product page as i've mentioned above and as long as the id is being passed in the URL using the correct URL parameter then this will filter your view to show the correct user.

Please let me know if this is clear or if further details are needed.

Thanks,
Shane

#1541019

Thanks Shane

Okay, good, at least I was on the right track! So I think I actually needed two views one for the User info at the top and another for their product listing beneath - which I've now done. I've also set them to filter by the param "lid" so that when someone goes to mysite.com/mypage?lid=30 it will filter the first view to show that relevant user's details, then the second view to only show products of which that same param matches the author ID.

The only one wee glitch I noticed is that although I have both views set to filter by that param, if I access the page with an invalid ID then I get the "not items found" message as expected, however if I access the page *without* the param altogether (so just mysite.com/mypage) then I get all results returned whereas I would rather it returned no results and/or the error message instead?

UPDATED:
I have put in place a function which copes with this as follows:

// REDIRECT IF THE PROFILE PAGE IS MISSING A PARAM
function redirect_from_profile($query) {

if($query->get_queried_object() !== NULL && $query->is_page(739)) {

if(!isset($_GET['lid'])) {

wp_redirect( 'hidden link' );
exit;
}
}
}
add_action('parse_query', 'redirect_from_profile');

Not sure if there is an option within Toolset to handle the fact that a missing param results in ALL results rather than NO results but at least my function works for me at the moment.

#1541143

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simon,

You can actually wrap the <wpv-loop></wpv-loop> code in our conditional code to check for the URL parameter.

Example

[wpv-conditional if="('[wpv-search-term param='lid']' ne '']<wpv-loop> my loop code</wpv-loop>[/wpv-conditional]

Please try this and me know if this helps.
Thanks,
Shane

#1541925

Duly noted - thanks for that Shane!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.