Tagged: guests, lightbox, mediapress
hi Brajesh,
I’m trying to modify the display of images for guests on the site, using MediaPress. At the moment I am applying a filter to mpp_get_media_permalink(), which should then return nothing or an empty string. However this is not working for me, and I expect it’s something simple. This is what I have:
function disable_images_for_guests( $media = null ) { if ( !is_user_logged_in() ) { return ''; } } add_filter( 'mpp_get_media_permalink', 'disable_images_for_guests' );
Pretty simple, and has no effect whatsoever… 🙂
Ideally I’d like to actually redirect as soon as a user clicks on a thumbnail “to view the image in the lightbox”, but just disabling the clickable link altogether (as above) should also work, I thought. Another approach might be to modify the shortcodes/grid-photo.php template. Do you have any better suggestions?
Many thanks in advance for any helpful tips.
R.
1. Please change the code to
function disable_images_for_guests( $permalink ) { if ( !is_user_logged_in() ) { return ''; } return $permalink; }
2. It will not link to the complete image(try right click and open)
3. To prevent lightbox, you will need to filter on lightbox response(If you need, I can share an example on how to ask users to register if the open an image in lightbox).
Regards
Brajeshok, I was close but no potato. With your suggestion, Brajesh, I get no right-click, however the lightbox still opens on a left-click, so the user gets the large image without needing to go to the gallery view itself. So, this doesn’t quite do what I need, although it does do exactly what I asked. 🙂
I’m also using “Simple Lightbox” to provide a simple… lightbox… (fyi.) Redirecting users to /login/ or /home/ if they’re not logged in would be the perfect solution, I think, if you have an example for that I’d greatly appreciate it.
R.
Hi Richard,
The lightbox uses data attribute to show the media/images. That’s why permalink does not have any effect on it.There are two solutions around this.
Strategy 1:-
1. We add a redirect for single media page to redirect to some page as per the need if the user is not logged.
2. We filter on settings to disable the lightbox for non logged.Strategy 2:-
This works by filtering the content of the light box. It will only work with our lightbox implementation.Before I share any code, Can you please link me to the code that you are using to use simple lightbox plugin instead of ours for showing the media in lightbox.
Regards
Brajeshok,
I think the lightbox (2) would be the preferred approach, as then we should catch all expanded media. I’m not doing anything special via code for the lightbox. I’m just using “Simple Lightbox” (https://wordpress.org/plugins/simple-lightbox/) and it seems to take over all lightbox related functions quite smoothly.
Presumably, if we filter the lightbox load mechanism, or the returned URL, then there becomes nothing to click, and non-logged-in (or whatever) users only see the existing thumbnail – which is the intention.
If this is clear…?
R.
Hi Richard,
I am sorry but I am not sure how are you able to use that plugin with MediaPress.Are you sure you are not using custom media loop or any js/css/php for it as out of the box, they can not work out of the box(specially showing the larger image on click).
Please recheck and let me know.
Regards
Brjeshhi Brajesh,
thanks for your patience here. Ok, well, it seems you are correct, I’m perplexed but double-checking shows no special media loops, no differences between when I enable/disable the Simple Lightbos, and if this changes I’ll let you know. However, to keep things simple I’ve disabled the Simple Lightbox now, just to be sure. So we’re only talking about your MP lightbox now. At least we’re on home ground 😉
R.
Hi Richard,
Thank you.Since you are using the MPP Lightbox now, we can go with any of the strategy. Which one will you like to go with?
Regards
Brajeshok Brajesh,
I think that having nothing to click will confuse people.
A redirect to /login/ when non-logged-in tries to open an image is the best way forward. It might be annoying, but that’s ok 😉
R.
- This reply was modified 5 years, 11 months ago by Richard Foley.
Thank you. I will post the code soon.
Please make sure to remove the code posted in the previous reply.
Regards
Brajesh
The topic ‘ [Resolved] Assist with lightbox display for guests’ is closed to new replies.