I wanted to share a useful modification for Osclass administrators who want more control over their site's content.
The Problem: By default, when a user edits their active listing, the changes are published immediately. This can be a problem if a user adds inappropriate text, links, or images, as this content goes live without any admin review.
The Solution: This simple code modification automatically sets any edited listing to inactive (b_active = 0), sending it back to the admin panel to be approved again. This ensures that you can review all changes before they are published on your site. It also provides a clear message to the user, letting them know their updated ad is now pending review.
How to Implement the Change
⚠️ Important: Before you begin, please make a backup of the file you are about to edit.
Step 1: Open the File
Open the following file using an FTP client or your hosting file manager: oc-includes/osclass/controller/item.php
Step 2: Find the Correct Section
Inside item.php, search for the following line to find the item edit section: case 'item_edit_post':
Inside this case block, locate the code that runs when an edit is successful. It looks like this: if($success == 1)
Step 3: Replace the Code
You will replace the contents of the if($success == 1) { ... } block.
FIND THIS CODE (The Original Code):
PHP
if($success == 1) {
if(is_array($meta)) {
foreach($meta as $key => $value) {
Session::newInstance()->_dropKeepForm('meta_'.$key);
}
}
Session::newInstance()->_clearVariables();
osc_add_flash_ok_message(_m("Great! We've just updated your listing"));
View::newInstance()->_exportVariableToView("item", Item::newInstance()->findByPrimaryKey($id));
$this->redirectTo(osc_item_url());
} else {
REPLACE IT WITH THIS CODE (The New Code):
PHP
if($success == 1) {
if(is_array($meta)) {
foreach($meta as $key => $value) {
Session::newInstance()->_dropKeepForm('meta_'.$key);
}
}
Session::newInstance()->_clearVariables();
// === MODIFICATION START: Deactivate item on edit for admin review ===
// Check the current status of the item
$dbItem = Item::newInstance()->findByPrimaryKey($id);
// Check if the item exists and is currently active
if($dbItem && isset($dbItem['b_active']) && (int)$dbItem['b_active'] === 1) {
// If it's active, set it to inactive (b_active = 0)
Item::newInstance()->update(
array('b_active' => 0),
array('pk_i_id' => $id)
);
// Show a clear message to the user that their ad is pending review
osc_add_flash_info_message(_m('Your listing has been updated and is now pending admin approval.'));
} else {
// If the item was already inactive, just show the standard success message
osc_add_flash_ok_message(_m("Great! We've just updated your listing"));
}
// === MODIFICATION END ===
View::newInstance()->_exportVariableToView("item", Item::newInstance()->findByPrimaryKey($id));
$this->redirectTo(osc_item_url());
} else {
What this new code does:
It removes the default "Great! We've just updated your listing" message.
It checks if the listing being edited was already active (b_active === 1).
If it was active, it updates the listing to be inactive (b_active = 0).
It then shows an informational message: "Your listing has been updated and is now pending admin approval."
If the listing was already inactive (e.g., already waiting for approval), it simply shows the standard success message without changing its status.
Disclaimer: Remember that editing core files can cause your changes to be overwritten during an Osclass update. For a more permanent solution, this logic could be implemented in a plugin using hooks. However, for a quick and effective solution, this method works perfectly.
Hope this helps other Osclass administrators!
Best regards.