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

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:

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.

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!

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.

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!

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!

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

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!

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.

Ok, thank you.

You are welcome @Simon_Matthews,

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

Thank you.