Skip Navigation

[Resolved] Display currently viewed user info outside loop

This support ticket is created 8 years, 5 months 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 34 replies, has 5 voices.

Last updated by Adriano 8 years ago.

Assisted by: Adriano.

Author
Posts
#346504

I apologize the delay here

I refer to this post as it seems all you need, is to return the proper ID with your ShortCode.
https://toolset.com/forums/topic/display-currently-viewed-user-info-outside-loop/#post-345261

It seems, inserting the ID (5) manually it works.

So what we need to discover is what your Custom ShortCode generates, on different User Profiles Viewed.

Please do this:
1. Insert your ShortCode just as-is on a few different user pages where you plan to sue the View
2. Tell me what you see, if you see the correct User ID or something else.

Then we can improve.

What I wanted to ask as well:
1. It seems you want a View (loop) that displays Posts of the user that you currently View.
2. Can you elaborate where you "view" that user?
- is the "user" a Profile Page created by a 3rd Party Plugin or a Custom post Type?
- Do you want each user on a single page, means each user is on another page, or, a List with all users and subsequently (for each user) their Posts?

Please could you provide me the additional Infos?

Thank you for your patience.

#346710

Hi Breda,

Please see my replies below:

1. Insert your ShortCode just as-is on a few different user pages where you plan to sue the View
- The shortcode is inserted in the profile page (hidden link)

User ID of profile being viewed: [getuserid]

2. Tell me what you see, if you see the correct User ID or something else.
- The correct user ID is being displayed (of the profile being viewed) whether someone is logged in or not.

What I wanted to ask as well:
1. It seems you want a View (loop) that displays Posts of the user that you currently View.
-That is correct
2. Can you elaborate where you "view" that user?
- is the "user" a Profile Page created by a 3rd Party Plugin or a Custom post Type?
-- That is correct. The page is created by a third party plugin called UPME (User Profiles Made Easy)
- Do you want each user on a single page, means each user is on another page, or, a List with all users and subsequently (for each user) their Posts?
-- Each user on a single page is fine.

The idea is that when you are viewing a profile (freelancer3) you will only see the "bookings" (custom post type) that have the same ID as the currently viewed user.

Thanks for your help
James

#346832

OK, I can not control if the ShortCode is really getting all ID's correctly, but we can tell, on that profile it's returning a valid ID.

As you can see in my example using Post ID, it is not supposed to work.

Anyway you can "knock out" views by passing the value manually, but please acknowledge that this is not the intended behavior.

So you can do a View listing Posts with ShortCode attribute "ID" and pass [wpv-post-id] as this attribute
That works, so should also our above example work.

However, on your end you will now see a edit, below your Post Content
It holds:

====================
BELOW IS TOOLSE TEST
====================
[wpv-view name="bookings-view" frid="[getuserid]"]
This is Toolsets gteuserid: [getuserid] 

As you can see on your front end, last line is blank (no output for [getuserid] )
So is your added line to demonstrate the shortcode output.

If your shortcode is present only ONCE on your Post Body, it works.

If it is added more then once also it's outputting the ID

But as soon you add a call for it in a View ShortCode, ALL the outputs break.

You can easily check that by adding your very own shortcode more then once in your Post Body
All outputs will be correct.
Add a View's call simultaneously and those will be empty.

I do not know why this happens and will need to ask assistance of my 2nd Tier Supporter.

Please also acknowledge that this involves Custom Code and we might be of limited assistance only.

Please expect my informations here in the forum.

Thank you for your patience.

#347557

Thanks for your reply and for correctly identifying the problem as I see it. Please let me know as soon as it is resolved.

#351282

Hi Pascal, we've updated Views in the past weeks. Would you mind updating your version and testing this issue again?

I've tried replicating it but couldn't see the issue happening on my local install.

Regards,
Yuri.

#351595
SHORTCODE_ISSUE.jpg

Hi,

I am up to date with all the plugins. Still no luck.

The strange thing is that it works in some places but not others. For example I am able to use the shortcode [getuserid] in a cred form to pull through the currently viewed users ID (different from the currently logged in user).

In the views code it just breaks though. See attached pic. Here is the shortcode again in case I have missed something:

add_shortcode('get_userid','get_userid');
function get_userid() {
	global $upme_api;
	$user_id = $upme_api->user_profile_id();
	return $user_id;
}

Thanks for your time.
James

#353825

Hi,

Any news on this issue?

Thanks
James

#356121

HI James, I'm checking on this issue right now.

I will update you as soon as I have any news.

Regards,
Yuri.

#358987

Hi James, I tried a couple of things directly on your site and noticed that the User Profiles Made Easy plugin might be interfering with the way the user ids are fetched in Views. Unfortunately UPME is integrated with your theme so turning it off breaks the page.

I tried generating a package with the Duplicator plugin (https://wordpress.org/plugins/duplicator/) so I could change a couple of things in a local environment without breaking your site. Unfortunately your server is triggering a 500 error when generating the package without displaying a usable error message. Would you mind taking a look at it and maybe contacting your webhost to verify the problem? Since this issue is eluding our normal support procedures this duplicator package is very important for our internal debugging process so we can replicate the issue correctly.

Let me know how it goes.

Regards,
Yuri.

#362612

Hi,

It took me a long time to figure out what was causing the 500 error but it should be resolved now.
Please try again.

Thanks for your patience
James

#364402

Hi James, I just tried to generate a duplicator package on your server and it triggered an error 500. Can you check and see if you server logs indicated something out of the ordinary?

Regards,
Yuri.

#364489

Hi Yuri,

Can't see anything strange on my side. Can I not generate a duplicate site for you and send it to you?

Thanks
James

#364500

Hi James, no problem. You can generate the package and just let me know then I'll download it directly from Duplicator's interface.

Regards,
Yuri.

#364939
Screen Shot 2016-02-05 at 10.49.29 AM.png

Hi,

I have generated a package for you to download. Let me know if you can't login for any reason.
FYI: I fixed the issue but changing the plugin settings (see screen shot).

Thanks
James

#368801

Hi Pascal, I've got the package in hand and I am already talking with our developers about this issue. Will update you as soon as I have any news.

Regards,
Yuri.

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