Watermark images only for some users

I figured out a sort of working solution, by using the plugin Image Watermark by dfactory.

The plugin has an option to back up all uploads, and by checking that in settings it uploads all your photos twice, with a backup in /wp-content/uploads/iw-backup/. What I did was enabling watermarking for all versions of the uploaded image, including the full one. And then let logged in users download the full resolution image from the backup-location. Not ideal, but at least the location isn’t just as obvious.

For anyone wanting to do the same, I had to comment out one line in the plugin code to make it work. To protect the images the plugin creates a .htaccess file to keep them safe. Deleting it will make it work one time, untill it creates it once again.

Comment out line 138 in image-watermark.php to prevent that from happening:

file_put_contents( IMAGE_WATERMARK_BACKUP_DIR . DIRECTORY_SEPARATOR . '.htaccess', 'deny from all' );

To send the visitor to the correct location, you have to build the correct url. That will look something like:

$folder = wp_upload_dir();
echo $folder['baseurl'] . '/iw-backup' . $folder['subdir'] . "https://wordpress.stackexchange.com/" . $image['filename'];

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)