Can I hide certain media (videos) from certain users (free subscribers)?

Hi gang!

I got some WONDERFUL help from @Michael Bissett on this thread, and I was wondering if I would possibly have any good luck again and get someone to help me out with a NEW problem I'm trying to figure out?! (I'm trying to learn some programming on my own, and I'm starting to put some of the pieces together here and there -- but I still need to learn a LOT).

In the previous thread we were able to come up with a solution for restricting uploads of videos to my site for free subscribers. Now I'm wondering if it's at all possible to also HIDE videos altogether for those same free subscribers.

I'm using the rtMedia plugin for uploads, and the s2Member plugin for Membership.
Unfortunately it's not like I have all videos relegated to a certain page -- because if that was the case, it would be really easy just to use s2Member to restrict access to that page for paid users only. Instead, videos populate the site in several places that free subscribers will have access too -- including many member's profiles.

So is it possible to HIDE videos for my free members? Or at the very least prevent them from playing them??

I asked the guys at rtMedia if they had any filters or hooks or whatever that would help in this situation, and this is what they said:

Yes, it is possible to hide media from certain member roles. Please have a look at the available hooks for SQL query to fetch media: https://github.com/rtCamp/rtMedia/blob/master/app/helper/RTMediaModel.php#L102 Using these filters, you can alter the SQL query to fetch media.

So apparently the rtmedia-model-select-query filter is the key, here. But...I know nada about altering SQL queries. Is this something relatively easy, or quite difficult to do?

Any help/suggestions/leads/clues/sample code that anyone could offer would be HIGHLY appreciated!
THANKS!!!!

  • Vinod Dalvi

    Hi @Anton,

    I hope you are well today and thank you for your question.

    We can certainly achieve this by developing some custom code.

    Instead, videos populate the site in several places that free subscribers will have access too -- including many member's profiles.

    Could you please share some of the URLs from your site where the videos are displaying so that i can help you to restrict the access of it?

    Are all these videos displayed by rtMedia plugin?

    So is it possible to HIDE videos for my free members? Or at the very least prevent them from playing them??

    Is free member the membership level of S2 Member plugin or are you referring the free members to the members not having any membership or you are referring the visitors who are not logged in to your site?

    Please advise.

    Kind Regards,
    Vinod Dalvi

  • Anton

    @Vinod Dalvi -

    We can certainly achieve this by developing some custom code.

    Great!! :slight_smile:

    Could you please share some of the URLs from your site where the videos are displaying so that i can help you to restrict the access of it?

    Are all these videos displayed by rtMedia plugin?

    Yes, they are are from rtMedia only.

    I can't give you access to the site, as the videos are private. But I made a similar test site with some of the exact same plugins, same theme, etc. I just granted support access to it (called "bosswebsite"). If you click on Activity, you can see an example of a video there.

    Is free member the membership level of S2 Member plugin or are you referring the free members to the members not having any membership or you are referring the visitors who are not logged in to your site?

    Yes, free membership is the S2Member level. Visitors and logged in members won't be able to see videos at all anyway. But I want it so free S2Members ALSO can't see videos. Only paid members should have this ability.

    Thank you for any help you can give!!

  • Ash

    Hello @Anton

    I hope you are well today.

    I am sharing you some code but you will need to modify a little:

    add_filter( 'rtmedia-model-where-query', 'protect_video_content', 99, 3 );
    function protect_video_content( $where, $table_name, $join ){
            if( is_user_logged_in() ){
                    $user_id = get_current_user_id();
                    if( is_free_member( $user_id ) ){
                            return ' where 2=2 and ID NOT IN (5616,1095,1357,271,2784,902) ';
                    }
            }
            return $where;
    }

    In line 5 you will see is_free_member function is used. This is not a valid function. You need to find out how we can get an users level by user id. Any hint from the s2member plugin developer would be great.

    In line 6, you will see "ID". I am not quite sure if this is a valid column name. You need to make sure with the rtMedia plugin developer about the correct ID column name.

    In the same line, "5616,1095,1357,271,2784,902" are the list if IDs you want to protect.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Anton

    Hi @Ashok !

    In line 5 you will see is_free_member function is used. This is not a valid function. You need to find out how we can get an users level by user id. Any hint from the s2member plugin developer would be great.

    In this thread about my other issue, @Michael used "s2member_level0" in his code, which in theory works -- though in S2Member I believe the default WP role "subscriber" is also the same thing. So I used his code, and just substituted "subscriber," and it works beautifully!
    So in your example, should I be replacing "is_free_member" with "subscriber"? Or do I replace "$user_id" with "subscriber"?

    In line 6, you will see "ID". I am not quite sure if this is a valid column name. You need to make sure with the rtMedia plugin developer about the correct ID column name.

    I will definitely ask the rtMedia guys about this, but first....

    In the same line, "5616,1095,1357,271,2784,902" are the list if IDs you want to protect.

    Ah, so does this mean this code is only for not showing videos with particular ID's? Is there a way to rewrite this to make it the reverse?
    Basically, the majority of videos that may show up on my site are NOT coming from me, but are uploaded by PAID users -- so there is no way I would be able to add all video ID's in this code, as it would be updating constantly.

    Uploading AND viewing videos is a paid-membership perk. I want to prevent free subscribers from being able to upload videos (already solved in previous thread) and from also SEEING any videos that a paid user uploads. So the code I was looking for was something that would basically apply to ALL videos to hide them from subscribers.
    Although... I just realized right now that there MAY be the occasional promo video that I DO actually want free users to see, so that's why I was asking if there was maybe a way to use video ID's for exclusion of invisibility instead.

    So is there way to re-write the code so that it hides ALL videos from free subscribers EXCEPT for the occasional video or two that I might want them to actually see?

    Thanks so much for all your help on this!!

  • Ash

    Hello @Anton

    I hope you are well today.

    though in S2Member I believe the default WP role "subscriber" is also the same thing. So I used his code, and just substituted "subscriber," and it works beautifully!

    In wordpress default user role is Subscriber, it doesn't matter in which level they are. Are you sure in your site only free users are subscribers and paid users have any other role?

    If Mike's code from other thread works for you, then you can try the following, with the changes of video IDs too:

    add_filter( 'rtmedia-model-where-query', 'protect_video_content', 99, 3 );
    function protect_video_content( $where, $table_name, $join ){
            if( is_user_logged_in() ){
                    if( current_user_is( "s2member_level0" ) ) {
                            return ' where 2=2 and ID IN (5616,1095,1357,271,2784,902) ';
                    }
            }
            return $where;
    }

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Anton

    @Ashok -

    In wordpress default user role is Subscriber, it doesn't matter in which level they are. Are you sure in your site only free users are subscribers and paid users have any other role?

    Paid subscribers have other member roles such as "s2member_level1," "s2member_level2," etc -- so it's all good!

    Thanks for the updated code!! I should still ask the rtMedia guys about the "ID" column name in line 65 though, correct? I'll let you know what they say, and then add this as a must-use plugin and tell you if it works!

  • Anton

    @Ashok -

    In wordpress default user role is Subscriber, it doesn't matter in which level they are. Are you sure in your site only free users are subscribers and paid users have any other role?

    Paid subscribers have other member roles such as "s2member_level1," "s2member_level2," etc -- so it's all good!

    Thanks for the updated code!! I should still ask the rtMedia guys about the "ID" column name in line 6 though, yes?

    Also...just for my own learning purposes here, what exactly in the code is targeting videos anyway? The " 'protect_video_content' " part is just a name that you gave this filter, right? Are "$where," "$table_name" and "$join" supposed to be exactly as is, or are they meant to be replaced with something else? I'm at the very beginning of my coding journey, and so this is all new to me -- I'm trying to figure out WHY elements are there, and it's not making sense to me... yet...

    Meanwhile, I'll let you know what the rtMedia guys say about that ID column name. Thanks again!

  • Ash

    Hello @Anton

    Also...just for my own learning purposes here, what exactly in the code is targeting videos anyway?

    You said, the rtmedia plugin have this filter for where query: rtmedia-model-where-query and I have used that:

    add_filter( 'rtmedia-model-where-query', 'protect_video_content', 99, 3 );

    You can learn more about Plugin API here: https://codex.wordpress.org/Plugin_API

    protect_video_content is a callback function, that is called in rtmedia-model-where-query hook. We can name anything to this callback.

    We don't need to alter the default join operation and the table name. We just need to change the where query. As per your requirement, you want to show certain videos for "s2member_level0" members. So, I have added the query "ID IN (5616,1095,1357,271,2784,902)" in the exisinting where query. "2=2" was already in the original code, we could omit that but I kept it as this condition always returns true :slight_smile:

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Anton

    @Ashok -

    Thanks so much for your explanations! You guys are really amazing with your help, and I'm really learning a lot with WPMUDEV membership. :slight_smile:

    Unfortunately it looks like this issue still needs to be worked out, as I'm running into some new problems -- though I'm confident we can figure out a solution!! First things first.... I had contacted the rtMedia guys, and gave them an example of your code -- asking them what else, if anything, might be necessary to make videos hidden for free subscribers.
    Here's what they wrote:

    The supplied code will allow only allow media with id 5616,1095,1357,271,2784 and 902 to be shown to *S2Member_level0* users.

    Please find updated code below for your requirement.

    They then supplied the following code:

    add_filter( 'rtmedia-model-where-query', 'protect_videocontent', 99, 3 );
    
    function protect_videocontent( $where, $tablename, $join ){
        if( is_user_logged_in() ){
            if( current_user_is( "s2member_level0" ) ) {
                $where .= ' and ( id IN (5616,1095,1357,271,2784,902) or media_type  "video" ) ';
            }
        }
        return $where;
    }

    They said:

    This will allow only certain videos to be shown to s2member_level0 users.

    So then I added this code as a must-use plugin (I didn't bother changing video ID's yet as I just wanted to see if it works first). I then logged in as a subscriber, went to the profile of a paid member who had some uploaded videos, and....the videos unfortunately still appeared. :slight_frown:

    I then tried it again with your code exactly as you had written it, logged in as a subscriber, went to the profile of the same paid member, and.... the videos still appeared!

    It looked like neither solutions were working as I had hoped, and I was about to come here and say it didn't work out....

    BUT THEN -- when I went to the subscribers OWN media, I realized...it was suddenly missing. (As a subscriber, they are only able to upload photos -- but they were now gone). When I removed the new must-use plugin I had added, and refreshed, suddenly the subscribers images were reappearing again!

    So basically....it looks like something IS happening with this code after all -- but it's only affecting the free subscriber's OWN media, and it's also affecting ALL media, not just videos. (The same scenario seemed to happen whether I used YOUR code or rtMedia's code).

    Instead, I need VIDEOS ONLY (not photos) to be hidden for free subscribers, and for ALL media on the site, not just the user's own (and with the exception of the ID's listed too).

    Now that I've explained what's going on, can you see what might need to be changed (in your code or theirs) to make my desired result a reality? We're so close!!! :slight_smile:
    Thanks

  • Ash

    Hello @Anton

    I think here are some confusions.

    So then I added this code as a must-use plugin (I didn't bother changing video ID's yet as I just wanted to see if it works first).

    You must give the video IDs, otherwise you won't see desired output. Maybe try with two video IDs first.

    As you have to show other media files, so you have to go with the first attempted method. Please try this:

    add_filter( 'rtmedia-model-where-query', 'protect_video_content', 99, 3 );
    function protect_video_content( $where, $table_name, $join ){
            if( is_user_logged_in() ){
                    if( current_user_is( "s2member_level0" ) ) {
                            return ' where 2=2 and ID NOT IN (5616,1095,1357,271,2784,902) ';
                    }
            }
            return $where;
    }

    It means 5616,1095,1357,271,2784,902 videos you don't want to show. Please try with two video IDs first.

    Also note that, this code will work only rtmedia-model-where-query is the correct filter.

    Let me know how it goes.

    Cheers
    Ash

  • Anton

    @Ashok

    I think here are some confusions.

    There are definitely some confusions going on here! I think I'm about to make it even more confusing, I'm afraid...

    You must give the video IDs, otherwise you won't see desired output. Maybe try with two video IDs first.

    It means 5616,1095,1357,271,2784,902 videos you don't want to show. Please try with two video IDs first.

    Just to be very clear on what I'm looking for: The video ID's are supposed to be for the "exceptions," right? The MAIN goal of this code is to make ALL videos hidden for free subscribers. In addition to this, there are one or two videos I might want to still show to them, and that's why I want to add their ID's to the code -- as exceptions to the hidden rule.

    Your wording above makes me think that you think I want ONLY those video ID's hidden, and the rest to be visible? I want the reverse!

    Still....I went ahead and tried exactly what you said anyway (using the code you supplied, and adding at least two actual video ID's), and got different results again. This time even worse...

    As I mentioned, in the previous version of the code (both yours and rtMedia's version) that used random ID's, ALL of the user's own media (including photos) was hidden when clicking on the "media" tab. (What I failed to mention, and only discovered afterwards, was that the user's media DID show up when looking at "activity.")

    This time (when I added the actual video ID's to the code), and I logged in as a free subscriber and clicked the "media" tab, ALL media (videos and photos) uploaded by ALL members (the free subscriber, paid members, everyone) showed up as thumbnails. (Well the videos, which normally have the same default thumbnail image, didn't have thumbnails -- only a blank space with the title). But ALL media was showing in some capacity...which is definitely not what I want, even under normal circumstances. (This view only showed up when logged in as a free subscriber. As a paid user, it was only showing that user's own media as intended).

    In addition, if I clicked on any of the media, no matter what it was, it ONLY ever showed the first media element on the list. Every time! Also...this "all media" view appeared when clicking on the "media" tab of EVERY person's profile, not just the free subscriber's own.

    So obviously this is even a worse scenario!

    It seems like ALL of these code attempts are affecting only the "media" tab, and not other instances of the media shown elsewhere on the site.

    To reiterate my main goal here:
    I want ALL videos (and only videos) to be hidden from view from free subscribers only, and in every place on the site (not just the "media" tab). Ideally I would also like a handful of videos (the ones with ID's written in the code) to be the "exceptions" from being hidden.

    If it helps, I made a copy of the site and just granted support access (it's the site with "robertsite" in the title). Hopefully we can finally get this all ironed out. I really appreciate the continued help with this!!
    Thanks

  • Ash

    Hello @Anton

    Well, as both plugins are third party and I am not familiar with those at all, so it is difficult for me to troubleshoot and provide you the correct code. I gave the code based on the filter you mentioned from rtMedia gallery.

    I can still take a look at your site, but to be honest, I can't confirm you :slight_frown:

    You will need to provide me admin login, ftp login and phpmyadmin/cpanel login of your test site. You also need to tell me the step by step procedure how I can reach in that page (I am sorry, but it will be easier for me to reach at the end).

    And again, I can't confirm but I will try my best.

    To send me details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question
    Subject: Attn-Ash (this ensures that it will be assigned to me)
    Details:
    1. Send all requested details
    2. Send a link of this thread so that I can track
    3. Send any other relevant link

    Cheers
    Ash

  • Anton

    Well, as both plugins are third party and I am not familiar with those at all, so it is difficult for me to troubleshoot and provide you the correct code. I gave the code based on the filter you mentioned from rtMedia gallery.

    I can still take a look at your site, but to be honest, I can't confirm you :slight_frown:

    I totally understand that you may not be able to find the ultimate solution, since these are 3rd party plugins (and not even the rtMedia guys got it right). But I REALLY appreciate you looking into it!!!

    I just sent my ftp details through the way you mentioned. Let me know if you're able to figure out something out. But if not, I still appreciate the effort!!

  • Anton

    @Ashok -

    In case you log in, the must-use plugin code is currently reverted back to rtMedia's version of it temporarily, since it seemed to be the closest to what I wanted to achieve so far -- though please feel free to change it to your heart's content if you think you've figured out a solution!

    I also let rtMedia know that their code was unfortunately making ALL MEDIA (photos AND video) be hidden only in SOME PLACES (the "Media" tab, widget galleries -- but still visible in activity), and that what I actually want is ONLY VIDEOS to be hidden in ALL PLACES instead (for free members only). Not sure if they'll respond or not, but I'll let you know if they do...

  • Ash

    Hello @Anton

    Thanks for sending FTP details, but I need more info that you missed in my previous reply :slight_smile:

    You will need to provide me admin login, ftp login and phpmyadmin/cpanel login of your test site. You also need to tell me the step by step procedure how I can reach in that page (I am sorry, but it will be easier for me to reach at the end).

    As I need to check the output, so please tell me the steps. Also, send me admin login too :slight_smile:

    Cheers
    Ash

  • Ash

    Hello @Anton

    I hope you are well today.

    Please check now. I needed the phpmyadmin info to check the column name. But no worries, I have installed the plugin myself and got the column name.

    I have made some modification in the existing code:

    add_filter( 'rtmedia-model-where-query', 'protect_videocontent', 99, 3 );
    
    function protect_videocontent( $where, $tablename, $join ){
        if( is_user_logged_in() ){
            if( current_user_is( "s2member_level0" ) ) {
                $where .= " and ( media_id IN (3393,3394) OR media_type != 'video' ) ";
            }
        }
        return $where;
    }

    Then I checked "dakmasters" profile media tab when I logged in as RojoTheBear and now I can see only two videos which IDs are 3393 and 3394 with the other media types.

    Please check and let me know.

    Cheers
    Ash

  • Anton

    @Ashok

    I hope you are well today.

    I am, thank you! Hope you're well too. :slight_smile:

    I have made some modification in the existing code:

    Definitely an improvement!!!
    The behavior that I want is definitely working when a free subscriber clicks on any "Media" tab in any profile -- so that part's good! :slight_smile:

    There are just two problems that remain, unfortunately:

    1). The videos that DO still appear (because we allowed them to with ID's), no longer show thumbnail images -- and they are just a blank space with the file title only. (rtMedia has a default thumbnail image for ALL videos, which I hate -- and I may need to set up a separate ticket to handle that. But in the meantime, even that is not showing).
    Granted, the videos that I DO intend to be viewable to free subscribers will NOT be in a member's media album anyway, and would be shown elsewhere on the site. But that's why I set up the widget in the sidebar of profiles which has "most rated media" as an example -- if you click on videos, you see one of the "allowed" videos, but without a thumbnail image. Is there any reason that you can think of that this is happening?

    2). Unfortunately this is an even more problematic issue: The one video that was supposed to still be hidden for the free subscriber STILL shows up in activity streams (both on the "Activity" page and the paid user's activity stream). If the video is still visible in places, then the whole point of trying to hide them for free members is pointless. The Activity streams will be very important on the site, and so I can't get rid of them. In fact, most media will be viewed on activity streams rather than the "Media" tab on profiles.

    We're definitely one step closer to where we needed to go!
    Seems like we're sooooooo close to a solution, but still coming up a bit short. If you have any more ideas, I'd love to hear them! In any case, I really do appreciate your help with this so far. rtMedia support will be back on line Monday, I hope -- and maybe they'll be able to chime in on this too. I'm determined we'll be able to find a solution to this together!!

  • Ash

    Hello @Anton

    The thumbnail images were broken before apply my code. I have removed my code and checked. Anyway, I have added some more code to put the rtmedia default image in there, please check.

    About the activity issue, I am not sure how to control that. You must need help with rtmedia guys on this. I am not sure how we can hide rtmedia videos from activity loop. Please let me know if you hear back from them about this.

    Cheers
    Ash

  • Anton

    @Ashok

    The thumbnail images were broken before apply my code. I have removed my code and checked.

    That's weird -- not sure what made them broken!

    Anyway, I have added some more code to put the rtmedia default image in there, please check.

    Cool, thanks!!
    Like I said, this isn't the actual site (which I'm working on locally) -- so if the same thing happens there, I may need to ask you how to add those default images back in....

    About the activity issue, I am not sure how to control that. You must need help with rtmedia guys on this. I am not sure how we can hide rtmedia videos from activity loop. Please let me know if you hear back from them about this.

    I'll let you know what the rtMedia guys tell me (probably nothing until Monday, at the earliest). At least your improved code might be able to steer them towards a final, workable solution -- so a sincere thanks from me for getting me this far!!!

  • Ash

    Hi there

    Like I said, this isn't the actual site (which I'm working on locally) -- so if the same thing happens there, I may need to ask you how to add those default images back in....

    To fix image, I have added the following code:

    add_action( 'wp_footer', 'set_default_video_thumb' );
    function set_default_video_thumb() {
        ?>
        <script type="text/javascript">
        jQuery(function($) {
            $('.rtmedia-item-thumbnail').each(function() {
                if($(this).find('.rtmedia_time').length)
                    $(this).find('img').attr('src', 'http://robertsite.antonkawasaki.com/wp-content/plugins/buddypress-media/app/assets/admin/img/video_thumb.png');
            });
        });
        </script>
        <?php
    }

    It's added in same file in mu-plugin. You just need to change the image url in there to change to another image :slight_smile:

    Cheers
    Ash

  • Anton

    @Ashok

    I just wanted to give you an update here!
    I heard back from rtMedia about whether or not videos in activity streams could also be hidden too. This is the new code they supplied to me:

    add_filter( 'bp_activity_get_where_conditions','rtm_custom_activity_get_where_conditions', 10, 5 );
    
    function rtm_custom_activity_get_where_conditions ( $where_conditions, $r, $select_sql, $from_sql, $join_sql ) {
        if( current_user_is( "s2member_level0" ) && function_exists('is_rt_admin') &&  !is_rt_admin() ) {
            $where_conditions['media'] = "(m.media_type != 'video')" ;
        }
        return $where_conditions;
    }

    It's one step closer to what I'm looking for, but....still not perfect, unfortunately!
    Video is definitely hidden in activity streams now for free users (and now this, combined with hidden videos in Media tab, means that the desired behavior for free members is FINALLY complete!!). BUT -- unfortunately now videos are also hidden in activity streams for non-free, non-admin members (basically, the "paid" members). I want THEM to see videos everywhere, just not the free members.

    So their new code was one step forward, but another step back. I let them know, and hopefully they can provide a solution. And I wanted to update you too, in case you can see a problem here that they might have made....

  • Anton

    @Ashok -

    UPDATE: So rtMedia said the code was working fine for them in their tests, and sure enough, when I added it back as a must-use plugin, suddenly it was working for me too.

    Perhaps some of the other stuff that was going on was interfering, or causing conflicts, but....it seems fine for the moment! I'll let you know if anything changes or seems odd, but for the moment consider this topic resolved....

  • Anton

    @Ashok -

    So sorry to re-open this thread, but apparently I hadn't done FULL all around testing of the Subscriber role across the entire site (I thought I had, but it looks like I was only testing the Media tab in profiles).

    Now when I'm logged in as a Subscriber, the videos are hidden, but NO activity feeds are showing anywhere. When I remove the must-use plugin above, then activity feeds return (but then so does the ability to see videos).

    Really sorry as I thought this was solved and I was going ahead with other parts of the site, and now I just realized it actually wasn't solved.

    So how can I keep videos hidden, but have Subscribers see everything else in activity feeds? What's wrong in the last supplied version of the code above? I'm going to ask the rtMedia guys too, since they are the ones that supplied me with this -- but asking here just in case you can see the problem...

  • Anton

    @Ashok -

    Ok, I just realized that something I've done since then is causing the activity feed to disappear with the plugin installed, and I actually DID test it properly before. (This is happening on my local development site, by the way. The "test site", where we we working on the "hide video" solution on this thread, seems to be working ok -- with videos being hidden from subscribers, and they are able to see all other activity. It hasn't been changed there, and I've been working on the local site since -- that's why I know it's something I've done since then that's somehow screwed it up).

    Let me see if I can figure it out the recent change that might be affecting it first, and then I'll get back to you....

  • Anton

    @Ashok -

    I'm officially stuck and can't figure out what happened!
    Could you please take a look at the "hide video.php" must-use plugin and see why it's not working the way it should? It DID work at one point, and I thought this was resolved....but now it doesn't (it now hides ALL activity from subscribers, but should only be hiding videos).

    Something that's changed since must have altered the way it works, but I don't know what that is.
    I'm hoping you can figure it out!

    Thanks.

  • Anton

    @Ashok -

    Did you get my email with the information?
    Just curious if you were able to check this out and see what the problem might be.

    This problem has really stumped me, and it is throwing the whole project off schedule. If we can't figure it out, I'll need to rebuild everything from scratch again to ensure the plugin continues to work as it's meant to. (And that will delay things for weeks).

    Thanks for looking into this.

  • Ash

    Hello @Anton

    I hope you are well today.

    I have taken a look at the code again. And at your site too. It looks like there is no activity? I can see no activity found.

    I have checked the code and looks okay, that we set some days ago. Just a note about the following code:

    $where .= " and ( media_id IN (3393,3394) OR media_type != 'video' ) ";

    So, are you sure those videos IDs are 3393 and 3394?

    And would you please add some videos and activities in there so that I can check? Please include any other relevant URLs that might help.

    Cheers
    Ash

  • Anton

    @Ashok -
    Thanks for taking another look!

    I have taken a look at the code again. And at your site too. It looks like there is no activity? I can see no activity found.

    Yes - NO activity is being shown for Subscribers (though activity DOES show for other user roles, and there's plenty of it to be seen). This wasn't the case when we first created the "hidevideos" must-use plugin. At that point, only videos were being hidden from activity for Subscribers. Now it's ALL activity for them!

    I have checked the code and looks okay, that we set some days ago. Just a note about the following code:
    $where .= " and ( media_id IN (3393,3394) OR media_type != 'video' ) ";
    So, are you sure those videos IDs are 3393 and 3394?

    Wait -- I'm seeing the ID's as 3394 and 3492. Are you looking at the must-use plugins folder of the site with the "Robert2" sub-domain? There were some other similar test-sites out there, and so I just want to make sure you're on the right one.

    Also, the ID's you gave are old ones. The video with the ID 3393 was removed, and so I replaced it with 3492 and then made the change in the code accordingly. Is the old code still being "used" somehow, and is that what's messing things up?

    Originally I wanted to have some videos be "exceptions" to being hidden for subscribers, which is why I wanted some code to include ID's of videos that can still be visible.
    HOWEVER -- I realize if the code ONLY works if these ID's correspond to videos that are actually there, then that could be a problem. If the videos are removed at any point, and that causes a problem, then... that's no good. Could we actually REMOVE this part of the code with the "exceptions"? It was only for rtMedia videos anyway, correct? If I REALLY need to show a video to subscribers, I suppose there are other ways I could do it that would still work, correct?

    And would you please add some videos and activities in there so that I can check? Please include any other relevant URLs that might help.

    There were already videos and other activity there. I added a couple of more just now.
    As I mentioned, activity DOES show up for everyone that's not a subscriber.
    Just go to ".../activity/" to see the main activity feed page.

    I'd love to know if this is fixable at all! If not, I need to start working on rebuilding everything from scratch ASAP. I'm hoping that won't have to be necessary....

    Thanks again!

  • Ash

    Hello @Anton

    The issue is not related to the hidevideos code, I have deactivated all code in that file (I left it deactivated) but still the subscriber sees no activity.

    So, the issue is something else. Please try to remember what changes you have made recently? Please try to roll back those changes.

    Let me know how it goes.

    Once this is fixed, we can discuss the video ID issue.

    Cheers
    Ash

  • Anton

    @Ashok -

    The issue is not related to the hidevideos code, I have deactivated all code in that file (I left it deactivated) but still the subscriber sees no activity.

    I don't understand, as I'm having different results. What do you mean when you say you "deactivated the code"? Is that something different than removing the plugin completely?
    This site is an exact duplicate of the local one I'm developing.
    On that site, when I log in as a Subscriber, there is no activity. When I simply remove the "hidevideo.php" plugin from it's folder temporarily, and refresh, the activity suddenly shows up!

    Also, I just realized -- there may be some Major confusion going on here. There are TWO live sites here that you might be confusing (three if you count my local site, but obviously you can't access that one). I was asking you in a previous message if you were looking at the correct site, which has the "robert2" subdomain. That's the one that's the exact duplicate of my current local site.

    However, when I look at the "modified" dates via FTP -- it looks like you were looking at the site with the subdomain "robertsite", as that site's "hidevideo" plugin has a modified date of several hours ago (I haven't touched these files recently, and I was also asleep at that time, so it must have been you). This is the site where the plugin works, and activity actually DOES show up for Subscribers (I just double-checked -- thankfully you didn't change anything here). You might have modified the plugin on this site (robertsite), and yet logged in on the other site (robert2), only to see activity NOT there.

    I'm sorry for the super-confusion there. The "robertsite" version I'm keeping around because there is where the plugin actually WORKS. And, if worse comes to worse and we can't figure out what's wrong with "robert2", then I'll have to go back to this version and redo everything else I've done since.

    I agree that something I've done since has somehow affected how this plugin works, but other than lots of "typical" minor Wordpress stuff and CSS tweaks, the only other major changes have been trying to implement personal blogs for member's profiles (another issue I'm trying to solve in THIS THREAD).

    So if you can please take another look, and make sure you're in the correct subdomain this time, I'd really appreciate it. If this problem can't be solved soon, I will need to resort to going back to the "robertsite" version. I know the sites seem similar, but when I duplicated the local site (as "robert2"), I removed a ton of private content -- and it's that stuff that will be take a week or two to redo all of that all over again. I'm trying to avoid all of that work as this site is super far behind as it is.

    Thanks!!

  • Ash

    Hello @Anton

    I hope you are well today.

    You are right! I was trying with old FTP.

    I have been checking with new FTP today, and yes I can see the issue. I have tried with different code but unfortunately no luck. The problem with the following code:

    add_filter( 'bp_activity_get_where_conditions','rtm_custom_activity_get_where_conditions', 10, 5 );
    
    function rtm_custom_activity_get_where_conditions ( $where_conditions, $r, $select_sql, $from_sql, $join_sql ) {
        if( current_user_is( "s2member_level0" ) && function_exists('is_rt_admin') &&  !is_rt_admin() ) {
            $where_conditions['media'] = "(m.media_type != 'video')" ;
        }
        return $where_conditions;
    }

    I hate to tell you to go with Plan B, but before that, as this code is given by rtmedia guys, would you please contact them again? Maybe they have released an update recently and that breaks the given code?

    Cheers
    Ash

  • Anton

    @Ashok -

    Just an update: Still waiting to hear back from rtMedia on this issue. They don't seem to think anything changed in any update to make the code suddenly not work. They also tested it elsewhere and it worked fine. So it does seem like something that's happened to the site SINCE has altered the behavior somehow. I can't for the life of me figure out what that can be., though...

    Disabling all plugins didn't change anything. The issue with trying to get a custom post to appear a certain way in the activity feed (the only major change since) doesn't seem like it would have any effect. There really isn't anything else major that I've done, other than some CSS changes, content additions, etc.

    I gave rtMedia admin access to the site, so not sure if they'll be able to find anything else on this or not. Will let you know if they so. It's definitely a big mystery!!

  • Anton

    @Ashok -

    Just wanted to update you here again.
    The issue is FINALLY resolved again, and the rtMedia people figured out what the problem was: The "privacy" setting was clicked off, and this was affecting the whole code and how it worked.
    (The scary thing is I had no reason, or memory, or turning off the privacy setting -- but at least the issue is finally resolved).

    Just wanted to thank you again for all the help you've given for this!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.