*

morfik

  • ****
  • 169 posts
Is there a way to prevent a listing from being removed?
« on: March 05, 2023, 05:16:03 PM »
Is there a way to prevent a listing from being removed by the user? I mean, is there an option to allow only admins to remove listings?

*

MB Themes

Re: Is there a way to prevent a listing from being removed?
« Reply #1 on: March 07, 2023, 01:19:31 PM »
@morfik
Well you can try to hide all remove buttons but still not supergood.

You could go to model/Item.php in core, find this line:
Code: [Select]
  public function deleteByPrimaryKey($id) {
and after it put:
Code: [Select]
if(!osc_is_admin_user_logged_in()) { return false; }
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

morfik

  • ****
  • 169 posts
Re: Is there a way to prevent a listing from being removed?
« Reply #2 on: March 07, 2023, 01:58:18 PM »
Hmm, I thought maybe there's some option I couldn't fine in the Osclass settings, similar to disabling a listing (allow user to disable their listings).

*

MB Themes

Re: Is there a way to prevent a listing from being removed?
« Reply #3 on: March 07, 2023, 08:19:28 PM »
No no such ootion exists.
You may use history logger plugin if you need to keep historical data - what listings you had
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

rooman

  • *****
  • 253 posts
Re: Is there a way to prevent a listing from being removed?
« Reply #4 on: June 05, 2025, 05:48:19 PM »
@morfik
Well you can try to hide all remove buttons but still not supergood.

You could go to model/Item.php in core, find this line:
Code: [Select]
  public function deleteByPrimaryKey($id) {
and after it put:
Code: [Select]
if(!osc_is_admin_user_logged_in()) { return false; }

This code worked in previous versions, but after updating to the latest version, it no longer works. Users can delete their ads. Is there an update to the code?

*

rooman

  • *****
  • 253 posts
Re: Is there a way to prevent a listing from being removed?
« Reply #5 on: June 08, 2025, 11:47:56 AM »
 :( :( :( :(
@morfik
Well you can try to hide all remove buttons but still not supergood.

You could go to model/Item.php in core, find this line:
Code: [Select]
  public function deleteByPrimaryKey($id) {
and after it put:
Code: [Select]
if(!osc_is_admin_user_logged_in()) { return false; }

This code worked in previous versions, but after updating to the latest version, it no longer works. Users can delete their ads. Is there an update to the code?

*

MB Themes

Re: Is there a way to prevent a listing from being removed?
« Reply #6 on: June 08, 2025, 02:38:06 PM »
There should be no change required
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

workapp

  • *
  • 1 posts
Re: Is there a way to prevent a listing from being removed?
« Reply #7 on: June 18, 2025, 08:22:58 AM »
Thanks for code.