Osclass Support Forums
Osclass plugin support => Osclass Pay Plugin => Topic started by: Sparky on December 07, 2021, 03:07:40 PM
-
Setting details below, am I missing a setting somewhere.
Admin Panel: Listings - (Only logged in users can post listings , I have this unchecked) so anybody can post Anonymous.
Osclass Pay Plugin: User Groups - Default - Max Items - 1 items in 30 days
STATER: Each new member is automatically placed in this group.
Free Membership with 2 free listings - 30day item period - 2 Max. Items in 30days
--------------------------
My problem: I tested the Anonymous posting and I can post as many times as I wish with a new email address... Why does it not limit it to just 1, as default. What am I missing.
-
@Sparky
Osclass Pay Plugin > User Groups (user groups ... not mail groups, anonymous group, no user groups :) )
User that does not exists, does not belong to any user group.
-
yes, I understand that, but how can we set the unregistered users limit or is there not any.
This is what it says under Default Max Items: Define default maximum items count that can be published in selected period. I.e. 10 listings in 30 days for "free". This value will be used for users those are not logged in or for those that are not member of any group.
-
@Sparky
countUserItems counts based on User ID or User email that is correct (you may review it)
osp_limit_items takes care of limit
Both looks correct and functional for logged & non-logged
-
All I know is, the limit for unregistered users does not work. I posted 3 listings freely with the limit set to 1 for non registered users.
Default Max Items: Define default maximum items count that can be published in selected period. I.e. 10 listings in 30 days for "free". This value will be used for ... (users those are not logged in or for those that are not member of any group).
-
@Sparky
Try to add following code to index.php of plugin:
// LIMIT WHEN POSTING A NEW LISTING
function osc_limit_items_posted() {
if(!defined('OC_ADMIN') || (defined('OC_ADMIN') && OC_ADMIN == false)) {
osp_limit_items();
}
}
osc_add_hook('posted_item', 'osc_limit_items_posted', 1);
If is working, would be good to test well also editing listing and adding/editing listing in backoffice that should not be affected.
-
I added it the bottom of the osclass pay plugin:
Line 963 to 970 with line 971 being ?>
// LIMIT WHEN POSTING A NEW LISTING
function osc_limit_items_posted() {
if(!defined('OC_ADMIN') || (defined('OC_ADMIN') && OC_ADMIN == false)) {
osp_limit_items();
}
}
osc_add_hook('posted_item', 'osc_limit_items_posted', 1);
?>
It did not stop me from posting but it did send a message: You have reached maximum number of listings you can publish (1 items in 30 days). Please upgrade your membership in order to increase your limits.
I think it is not recognizing the email address being used with unregistered users because you have to an email address to post.
-
Oh right we must use hook that is before listing is created
-
I assume this will be added in an update.
-
@Sparky
yes in one update it will be included :)
In index.php find this line:
osc_add_hook('posted_item', 'osc_limit_items_posted', 1);
change it to:
osc_add_hook('pre_item_add', 'osc_limit_items_posted', 1);
So check will be made before listing is actually created in database.
-
Thanks, it works great with unregistered or non logged members. I also checked it by changing the default max limit to 2 and tried to post 3 ads, again, no issues. 8)
-
@Sparky
Finally :D