Is there a way to disable the rtMedia lightbox description/meta box for non-logged in users


#1

Hi,

I am using the default rtMedia lightbox to display a public rtMedia gallery on my website. Is there a way to disable the image description/meta content box on the right of the image just for non-logged in users?

Thanks :slight_smile:


#2

Hello @Simon_Matthews,

You can try adding below code to your theme’s functions.php file :

add_action( 'init', 'custom_function_hide_lightbox_meta' );
function custom_function_hide_lightbox_meta() {
    if ( is_user_logged_in() ) {
        ?>
        <style>
             .rtmedia-single-container .rtm-lightbox-container .rtmedia-single-meta {
                  display:none;
             }
             #rtmedia-single-media-container {
                   width: 100%;
             }
       </style>
        <?php
    }
}

I hope this will help you.

Thank you.


#3

Hello @pranalipatel,

Thank you so much for your help! I had to change your code slightly for it to achieve my goal. My goal is to hide the description box for logged out users, but your code hid the description box for logged in users, so I needed to swap the conditions around. I have never coded in PHP before so I am not sure what I am doing. I made the following alterations:

add_action( ‘init’, ‘custom_function_hide_lightbox_meta’ ); function custom_function_hide_lightbox_meta() { if ( is_user_logged_in() ) {

}
else {
	?>
    <style>
         .rtmedia-single-container .rtm-lightbox-container .rtmedia-single-meta {
              display:none;
         }
		 #rtmedia-single-media-container {
               width: 100%;
         }
   </style>
    <?php
}

}

As you can see, I have added an ‘else’ to the code and left the first part of the ‘if’ statement blank. It works but I was wondering if there was a better way of writing the code?

Thanks again for your help!


#4

Hello @Simon_Matthews,

Oh yes, for non-logged in users the condition will be used in reverse. You can use !is_user_logged_in() condition.

For example :

add_action( 'init', 'custom_function_hide_lightbox_meta' );
function custom_function_hide_lightbox_meta() {
   if( !is_user_logged_in() ) {
        ?>
        <style>
             .rtmedia-single-container .rtm-lightbox-container .rtmedia-single-meta {
                  display:none;
             }
             #rtmedia-single-media-container {
                   width: 100%;
             }
       </style>
        <?php
    }
}

Thank you.


#5

Hello @pranalipatel,

Thank you very much! That worked!

This is a very good customization as it can be used to implement galleries that are available for both the public and for registered members, but with the uploader’s ID only visible to registered members and not visible to the public.

Thanks again for your excellent work!


#6

Hello @pranalipatel,

I spoke too soon! The code does work but for some reason it messes with the look of lots of different elements on my website, such as the height of certain elements.

Here is a link to my website, where you will see the issue:

If you scroll down you will see the issue.

Any ideas why this is happening?

Thanks!


#7

Hello @pranalipatel,

It’s OK, I have now corrected the issue. I simply had to alter the styling of the broken elements. It is now all working correctly!

Thanks again for your help and patience!

Simon


#8

Hello @pranalipatel,

Sorry, I spoke too soon again! On my website, any elements with ‘equal height of items in wrap’ are all displayed incorrectly as a result of the above code. I believe this is a theme issue with BeTheme, or with the Muffin Builder that comes with the theme. It is a pity because the code works perfectly otherwise. For now I have not used the code until a fix for this issue is found.

Thanks for helping me out though!


#9

Hello @Simon_Matthews,

We also believe that your issue is related to the theme you are using and hence we suggest you to once contact your theme developers. We hope they can help you out with the issue.

Thank you.


#10

Ok, thank you.


#11

You are welcome @Simon_Matthews,

I am closing this thread for now. Feel free to create new if you need any assistance.

Thank you.


#12