Skip Navigation

[Resolved] Display a conditional field for logged in users only with Elementor

This support ticket is created 3 years, 2 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 13 replies, has 2 voices.

Last updated by korieF 3 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2174151

Tell us what you are trying to do?
On my woocommerce account page, I want to add an extra link/button that only displays for logged-in users. The link is to a database webpage I created using toolset. Only logged in users have access.

Is there any documentation that you are following?
This seems like exactly what I need, except I am using elementor to build the page. https://toolset.com/lesson-placement/lesson-placements-1719471-1719351/ I also saw some other help forums that discussed adding code, but I didn't find anything regarding logged in user access, only fields.

What is the link to your site?
hidden link

#2174955

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can add a conditional block and set your conditional block to check against the current user Id is not empty.

Please check the following screenshot:
=> hidden link

You can setup that conditional block and within the conditional block you can add whatever you want to display when current user Id is not empty.

#2175203

Hi Minesh,
Yes, thank you. I do understand how to do this in the regular block builder. But, I am using elementor. Do you have tips for how to get these same results with elementor?

#2175737

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can use the [wpv-conditional] shortcode.

You should try to add the elementor's text module and then add the [wpv-conditional] shortcode.

For example:

[wpv-conditional if="('[wpv-current-user info='id']' ne  '')"]
User is logged-in
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/#checking-for-the-current-user-data

#2176559

I tried using this shortcode, but the new buttons still show up on the account page for non-logged in users.
hidden link

#2176895

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please send me admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2181457

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please share bit more details what buttons you are talking about and where exactly you added the conditional shortcode I shared?

Please note that you can add conditional shortcode within elementor template either within the Text module or Shortcode module.

#2182005
Screen Shot 2021-09-28 at 8.40.32 AM.png

Hi Minesh,
I included a screenshot with the buttons I do not want to appear for not-logged in users. ("Access the new material and activity database" and "Write your own activity for your materials") They should only appear for logged in users. The buttons are the ones at the bottom of this login screen. They should only be appearing on the logged in dashboard and not here.

I have since removed the shortcode because it did not work. I added it into the elemetor text module and also tried it in the shortcode as you said.

Thanks for any assistance!

#2182015

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Please note that you can not wrap any elementor module with the conditional shortcode.

You should try to add conditional shortcode within the text module or shortcode module and within the conditional (within the text module) you will have to add the add the buttons HTML.

Can you pleases share buttons HTML that you want to display and I will wrap the conditional statement with that shared HTML.

#2182019

I do not know what you mean by sharing the buttons HTML. Do you mean I need to recreate the button in HTML and then add that to the page?

#2182027

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - exactly.

I've added the conditional shortcode using the Text module:
=> hidden link

You need to add the button HTML within the conditional shortcode. You can not wrap the elementor's element using Toolset conditional shortcode.

You should be able to see the text "User is logged-in — your button HTML should go here" when loggedin.
=> hidden link

#2182041

Okay, I'm realizing I might be needing more than just this because I actually need that entire boxed element to not appear, not just the buttons. And since I can't wrap the elementor element, then I don't think this will work how I need it to.

#2182523

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

To display the elementor modules conditionally, I seems you should try the following plugin:
=> https://wordpress.org/plugins/dynamicconditions/

#2188009

My issue is resolved now. Thank you!