• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

[SOLVED] I want to add a shortcode to set visibility depending on user role in WP

AlanVernet

Active member
May 4, 2022
56
129
33
Hi all,


It has been a week of trying to come up with a workaround for this. I have zero knowledge in coding and bootstrapping my own site. Figured I should ask experts around to solve this faster.

  • Title for your fault: I want to add a shortcode for setting visibility of button depending on user role
  • Fault Description: I'm using Vex 1.2.3 theme by Rascals. They have a shortcode for adding a Download button on a track but I want that button to be hidden if user is not logged in. I have no experience in coding whatsoever.
  • What have you done to try to fix the issue: I've tried adding If-So plugin, I've read this article which I think would solve my issue but I don't know where to add it within the php files. I think I found which php file to edit but I'm clueless as to how to implement this.

If it would help, here are a few more details:

1. The section I'm working on is in Beatsunlmtd.com
2. Right side of the track "Work Hard" is a download button
3. The shortcode to make that visible is [player_button title="Download" link="http://link_here" target="_self"]
4. The theme file can be found here: https://babia.to/resources/vex-creative-music-wordpress-theme.20324/


Thanks so much! Long live Babiato.


Alan
 
Try this CSS. Make sure to clear the website cache after.
CSS:
.audio-player__buttons a {
    display: none!important;
}
.logged-in .audio-player__buttons a {
    display: inline-block!important;
}
Easy fix, but not safe.

Someone could just play around with the .logged-in class and taddaaah!

He/she needs the validation to be done in the code.
 
Hey there!

This actually worked! You're a life saver. Though @tradesman mentioned that it is unsafe. It'll do for now until I find a more solid solution.

Now that the inspect element part was mentioned, I can see that the link to the S3 bucket where the mp3 files can be downloaded are also exposed.

A bit worried about that but I don't have the bandwidth do deal with that right now.

If you can offer another expert advice on this. I'll take note and execute when I can.

Thanks again!


Try this CSS. Make sure to clear the website cache after.
CSS:
.audio-player__buttons a {
    display: none!important;
}
.logged-in .audio-player__buttons a {
    display: inline-block!important;
}
 
  • Like
Reactions: xsz
Easy fix, but not safe.

Someone could just play around with the .logged-in class and taddaaah!

He/she needs the validation to be done in the code.

Hey there!

Thanks for your suggestion! It actually made me realize that there's another vulnerability that exposes the S3 bucket that stores the files I'll be sharing only to logged in users.

I went with the quick fix for now until I find a better solution like the validation being done in the code which I don't know how to do. If you can shed some light on how to do this, It'd be very much appreciated!


Thanks again!
 
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock