Skip Navigation

[Resolved] wpv-conditional, Current user = UserID of another user profile page being viewed

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the customer wanted to check if the current logged in user is the same as the author of the post they are viewing and if they are to display some information.

Solution:

To do this you will need to use the conditional shortcode below.

[wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='id']')"]
This support ticket is created 6 years, 11 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.

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)

This topic contains 4 replies, has 3 voices.

Last updated by Shane 4 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#609794

Tell us what you are trying to do?

We have a buddypress website, it shows a list of posts created by a user, what we want is when a user is viewing someone else user profile page to not show part of a view.

I though I could use a [wpv-conditional] command to do this, this is what I have.....

[wpv-conditional if="('[wpv-current-user info='ID']' eq '[wpv-user field='ID']')"]

basically I need the statement to work in this way...

IF 'the current logged in user' IS THE SAME AS 'Buddypress/WP user profile I am viewing'

#609852

Shane
Supporter

Languages: English (English )

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

Hi Steve,

Thank you for contacting our support forum.

Lets see if I can get an understanding here. Are the user profile saved as a Profile CPT? Are the users Authors of their own profiles ?

What you can try doing is this.

[wpv-conditional if="('[wpv-current-user info='ID']' eq '[wpv-post-author format='meta' meta='ID']')"]


Please try this and let me know if it helps.

Thanks,
Shane

#610210

Hi there,

Many thanks, I couldn't get the code to work, but I used a work around and hidden the buddypress tabs instead,

Many thanks for your help:)

#1593601

The code is correct. Change uppercase ID to lowercase id:
[wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='id']')"]do something[/wpv-conditional]

#1593637

Shane
Supporter

Languages: English (English )

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

Hi Chuck,

Thanks for the checking in.

I've updated the code accordingly to your advise.