• I have a site with s2member and nextgen gallery, I want to protect the content under the nextgen gallery «gallery» folder. I have tried this code from Cristián Lávaque to change the s2member protected folder:

    ` <?php
    add_filter(‘ws_plugin__s2member_files_dir’, ‘ngg_gallery_directory’);
    function ngg_gallery_directory() {
    return ‘http://mysite.com/wp-content/gallery/&#8217;;
    }
    ?>`

    Then I have added a «download» button in the gallery page:
    <a class="download-link" href="<?php echo $image->imageURL ?>">Download</a>

    Following the instructions of S2member > Download options > Basic downloads restrictions, I can link to any protected file using:
    http://mysite.com/?s2member_file_download=example-file.zip

    So, the download button now look like this:

    <a class="download-link" href="http://mysite.com/?s2member_file_download=<?php echo $image->imageURL ?>">Download</a>

    The final URL looks like this:

    http://mysite.com/?s2member_file_download=/gallery01folder/gallery01image_01.jpg

    But I get an 404 error from s2member:

    404: Sorry, file not found. Please contact Support for assistance.`

    Surely I’m doing something wrong, I have uploaded the same folder with the files to the s2member-files folder and I can download them, so the folder-changing-hack is not working, I guess.

    Can you please help me to protect the «gallery» folder?

    Thanks!

    https://wordpress.org/plugins/s2member/

Viewing 7 replies - 1 through 7 (of 7 total)
  • I don’t use NextGen Gallery, but the thing that’s confusing me here is that you’ve apparently set up the ~/gallery/ folder to be protected, and then used code that links to a folder called ~/gallery01folder/ Surely they need to be the same?

    Thread Starter McKrank

    (@mckrank)

    The s2member_file_download equals to the protected folder, by default it is s2member-files folder, located in wp-content/plugins, so this:
    http://mysite.com/?s2member_file_download=/gallery01folder/gallery01image_01.jpg
    becomes this:
    http://mysite.com/wp-content/plugins/s2member-files/gallery01folder/gallery01image_01.jpg

    I want to protect the gallery folder located in wp-content, just that. As I said before it works well when the content is in the default folder.

    Thanks for your help!

    Have you tried using the full URL?

    Thread Starter McKrank

    (@mckrank)

    I have confirmed that the «change your protected folder via s2hack.php» code does not work for me.

    This is the code I’m using:

    <?php
    add_filter('ws_plugin__s2member_files_dir', 'ngg_gallery_directory');
    function ngg_gallery_directory() {
    return ABSPATH.'/wp-content/gallery/'.((stripos(PHP_OS, "win") === 0 && stripos($_SERVER["SERVER_SOFTWARE"], "apache") === false) ? "/app_data" : "");
    }
    ?>

    I also have tried return 'http://mysite.com/wp-content/gallery/';

    I have uploaded an entire gallery to the s2member-files folder and everything works, I got the JavaScript confirmation prompt and the file is downloaded to my computer. I have a large number of galleries in the NextGen gallery folder, so, it is not viable to move them to the s2member-files folder.

    Please help!

    Thread Starter McKrank

    (@mckrank)

    @kts915 yes, I have used the full URL, as I said, the protection works just fine when the images are in the s2member-files folder but I get the 404 error if I try to dowload from the gallery folder.

    Shouldn’t the code be:
    return 'http://mysite.com/wp-content/plugins/gallery/';

    Thread Starter McKrank

    (@mckrank)

    Nope, the folder is inside wp-content, not inside wp-content/plugins. At the same level of uploads and plugins.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘S2 member Nextgen gallery’ is closed to new replies.