Charging Points to Add Image and Add Video

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5682 (In Topic #1170)

How to disallow adding images and videos based upon points.

I appreciate any help you may offer.

I am trying to charge members points in order to add images or videos.  I went into Setup---->Configurations---->Point Options and set "Points Given" to Add Image to -5 (a negative number).  5 Current Points are deducted from the member on image upload.  I can see this in a member's Profile that this works fine.

Here's the problem:
 
I only want the image to be uploaded if the member has enough Current Points for the transaction.  If the member does not have enough points, the image should not upload.

After doing what I described above, the member now has "Current Points: -5 to spend".  The upload was allowed with a negative result of points.

Setting Security--->Privileges---->Points to not allow negative points only refers to "Gift Points".  Images added are deducted from "Current Points".

I know this is usually done within the query to the database, but I can't figure out how to do this.

Hoping that someone has an idea.  Thanking you in advance.
 
 

Post

Posted
Rating:
#5683
Hi,

Your approach is smart :) .
Unfortunately Composr isn't coded to know what you're doing, so it would need implementing. We've had an issue on the tracker a while for this request:
0000045: Implicit point store - charging to add content - Composr CMS feature tracker

Post

Posted
Rating:
#5684
Thank you so much for replying so quickly, Chris.

Since reading your reply, I have been trying to learn about CRUD.  I'm pretty much a beginner, so I've got a lot to learn.

I'm not giving up!
 

Post

Posted
Rating:
#5686
I am still at a loss about CRUD.

What if I made the button to "ADD IMAGE" invisible (Content Management--->Galleries--->ADD IMAGE page) if a query to the database reveals the user does not have enough Current Points (using Operators)?

How should I go about this?

Post

Posted
Rating:
#5687
Properly learning CRUD is diving in at the deep end. If you want to change existing behaviour you'd be better off just experimenting changing existing code on a line-by-line level. That's how I learned coding (30 years ago, lol).

Also just changing the icon isn't going to be a secure solution, as if a user could find the direct URL they'd bypass the check, and if that was also checked, they could simulate a form submission, so you'd need to add a check in the actualiser code.

I'd start by just trying to disable the form if there isn't enough points. That doesn't fix the aforementioned actualiser issue, but I think it's better than just disabling the icon as casual users are not going to be simulating form submissions but they might be bookmarking form URLs.

So find the get_form_fields functions for images and videos in cms_galleries.php and I think you'd need to add some code to them something like:

Code (PHP)

if (available_points(get_member()) < 50) {
    warn_exit('You do not have enough points, you need at least 50');
}
 

Obviously this is hard-coding it in a not completely secure way for just a couple of content types, while the tracker issue is to do a more comprehensive, secure, solution. But if it does what you need…

Post

Posted
Rating:
#5688
Thanks again, Chris!

I will keep reading about CRUD.  Unfortunately, I couldn't even find the location of the CRUD module to view it.  I did read the tutorial a few times, and searched for additional explanations.  It was beyond this beginner's skill set.  I thought that having the add button appear or not appear on the page might be a solution I could handle, but I wasn't sure if this was okay to do.  Thanks for explaining!

As a side note, your tutorials, documentation, and videos are excellent resources!  I've learned a lot already.  Thank you!

Post

Posted
Rating:
#5691
I am so sorry Chris.  I wasn't able to implement the code correctly.

Post

Posted
Rating:
#5692
I wouldn't honestly expect most users to be writing code. I don't want to put anyone off, it's a great rewarding thing, but it's  a lot to learn.

Post

Posted
Rating:
#5693
Maybe we can cover this in some kind of public live coding session/lesson.

Post

Posted
Rating:
#5694
That would be fantastic, Chris!  Thanks so much!!!




 

Post

Posted
Rating:
#5704
Not that I am sure how to do this, or if this is reasonable, but I was thinking...

What if a hidden field was passed with the value of Available Points, when the user goes to the page to upload an image or upload a video (after clicking on "Add Image" or "Add Video" buttons).

Would the Field Filters (Setup-->Field Filters) be able to stop the upload, based upon that hidden field's value (using operators)?

Again, not sure how to correctly implement this but I can't stop thinking about what might work.

I am looking forward to Chris Graham's lessons!

Post

Posted
Rating:
#5712
I'd avoid convoluted solutions, they will be a problem to maintain as you try and do more things or do upgrades. Besides, a more direct solution would be simpler.

I'm thinking about how we can do a programming session at the moment. Will you be around for the next hour or two? (It won't take that long, but I've got to work out how to do it)

Post

Posted
Rating:
#5713
Wonderful!  I am here!
 

Post

Posted
Rating:
#5714
I think I'll be streaming on Twitch, which I'm setting up now. Anyone wanting to have the latest info, best to be in IRC for it.

Post

Posted
Rating:
#5715
I'm sorry, I don't know how to connect to view.
 

Post

Posted
Rating:
#5716
I've never used Twitch before either. I think you'll need an account on Twitch.tv and I'll need to tell you the channel name (which is ComposrCMS). I think you'll then be able to do text chat while I'm streaming and see my screen and camera.

Post

Posted
Rating:
#5717
Pretty sure you can view streams without an account, same as Youtube.

Post

Posted
Rating:
#5718
Great!  I'm on twitch.tv website.  There is something streaming on the screen.  There is a list of Recommended Channels on the left sidebar.

Post

Posted
Rating:
#5719
Probably an account will be needed to chat, but I know some places allow Guests to comment on streams. I'm not familiar with Twitch.tv either.

Post

Posted
Rating:
#5720
Just joined.  Says you are "offline".
0 guests and 0 members have recently viewed this.