This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

Sparky

  • ***
  • 84 posts
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.

*

MB Themes

Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #1 on: December 07, 2021, 03:09:43 PM »
@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.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Sparky

  • ***
  • 84 posts
Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #2 on: December 07, 2021, 03:19:01 PM »
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.

*

MB Themes

Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #3 on: December 07, 2021, 03:56:12 PM »
@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
« Last Edit: December 07, 2021, 04:00:40 PM by MB Themes »
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Sparky

  • ***
  • 84 posts
Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #4 on: December 07, 2021, 05:18:38 PM »
 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).
« Last Edit: December 07, 2021, 05:20:57 PM by Sparky »

*

MB Themes

Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #5 on: December 08, 2021, 12:54:31 PM »
@Sparky
Try to add following code to index.php of plugin:
Code: [Select]
// 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.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Sparky

  • ***
  • 84 posts
Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #6 on: December 08, 2021, 08:24:30 PM »
 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.

*

MB Themes

Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #7 on: December 08, 2021, 09:43:58 PM »
Oh right we must use hook that is before listing is created
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Sparky

  • ***
  • 84 posts
Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #8 on: December 09, 2021, 11:53:57 AM »
 I assume this will be added in an update.

Marked as best answer by frosticek on December 09, 2021, 01:18:06 PM
*

MB Themes

Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #9 on: December 09, 2021, 12:03:36 PM »
@Sparky
yes in one update it will be included :)

In index.php find this line:
Code: [Select]
osc_add_hook('posted_item', 'osc_limit_items_posted', 1);

change it to:
Code: [Select]
osc_add_hook('pre_item_add', 'osc_limit_items_posted', 1);

So check will be made before listing is actually created in database.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Sparky

  • ***
  • 84 posts
Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #10 on: December 09, 2021, 12:30:32 PM »
 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)

*

MB Themes

Re: Unlimited Posting by unregistered (Anonymous) with default set as 1
« Reply #11 on: December 09, 2021, 01:18:00 PM »
@Sparky
Finally :D
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots