Send again edit/delete link to manage ads for non register users
on :February 23, 2023, 4:58 pm #679
Hi
Is there any way to send, at the user's request, another email with a link to edit/delete the ad?
If an unregistered user adds an ad, he receives a link with which he can edit or delete the ad. But what if he deletes the email?
I know that there is no such function in osclass - I tried to use the "Send classified to friend" mechanism for this (it sends the ad link to our friend on request). Instead of to a friend, you can send the link to the owner of the ad, but I don't know how to make a link to edit/delete the ad.
Does anyone know how to do this?
Re: Send again edit/delete link to manage ads for non register users
on :February 23, 2023, 9:43 pm #680
I think that an unregistered user can edit an ad only for a specific time. After that time pass the item cannot be edited if I remember right.
Re: Send again edit/delete link to manage ads for non register users
on :February 24, 2023, 12:18 pm #681
Hi
I found ads added 5 years ago - I used link to edit/delete ad and it work fine.
But I don't know how to used e.g. "sent to friend" function to send links to ad owner.
Do you have any idea?
Re: Send again edit/delete link to manage ads for non register users
on :February 27, 2023, 4:12 pm #682
@calinbehtuk could You help me with sending again code to edit/delete offer?
in /oc-includes/osclass/emails.php is:
function fn_email_send_friend($aItem){}
oryginal fn is sending information about offer in osclass.
If I change this function to:
function fn_email_send_friend($aItem) {
$title = 'This is test of the title';
$body = 'This is test of the message';
$emailParams = array(
'from' => _osc_from_email_aux(),
'from_name' => osc_page_title(),
'to' => $user['s_email'],
'to_name' => $user['s_name'],
'subject' => $title,
'body' => $body
);
osc_sendMail($emailParams);
}
osc_add_hook('hook_email_send_friend', 'fn_email_send_friend');
I will recive mail with "This is test of the message". Could You help me to put in $body "secret" code to edit/delete link?
Re: Send again edit/delete link to manage ads for non register users
on :February 27, 2023, 6:32 pm #683
You cannot use the send friend option. Is more complicated.
Re: Send again edit/delete link to manage ads for non register users
on :February 27, 2023, 7:34 pm #684
You can try by adding this code in functions.php from your theme, or index.php in an active plugin.
A new option in admin items table will appear on items that don't have an user.
function cbk_r_resend_email_action() {
$action = Params::getParam('action');
$page = Params::getParam('page');
$itemId = Params::getParam('id');
if ($page == 'items') {
switch ($action) {
case('resend_edit_email'):
$item = Item::newInstance()->findByPrimaryKey($itemId);
if (!empty($item)) {
View::newInstance()->_exportVariableToView('item', $item);
$item_url = osc_item_url();
$item_url = '<a href="' . $item_url . '" >' . $item_url . '</a>';
$edit_url = osc_item_edit_url($item['s_secret'], $item['pk_i_id']);
$delete_url = osc_item_delete_url($item['s_secret'], $item['pk_i_id']);
$mPages = new Page();
$aPage = $mPages->findByInternalName('email_new_item_non_register_user');
$locale = osc_current_user_locale();
$content = array();
if (isset($aPage['locale'][$locale]['s_title'])) {
$content = $aPage['locale'][$locale];
} else {
$content = current($aPage['locale']);
}
$words = array();
$words[] = array(
'{ITEM_ID}',
'{USER_NAME}',
'{USER_EMAIL}',
'{ITEM_TITLE}',
'{ITEM_URL}',
'{ITEM_LINK}',
'{EDIT_LINK}',
'{EDIT_URL}',
'{DELETE_LINK}',
'{DELETE_URL}'
);
$words[] = array(
$item['pk_i_id'],
$item['s_contact_name'],
$item['s_contact_email'],
$item['s_title'],
osc_item_url(),
$item_url,
'<a href="' . $edit_url . '">' . $edit_url . '</a>',
$edit_url,
'<a href="' . $delete_url . '">' . $delete_url . '</a>',
$delete_url
);
$title = osc_mailBeauty($content['s_title'], $words);
$body = osc_mailBeauty($content['s_text'], $words);
$emailParams = array(
'from' => _osc_from_email_aux(),
'to' => $item['s_contact_email'],
'to_name' => $item['s_contact_name'],
'subject' => $title,
'body' => $body,
'alt_body' => $body
);
osc_sendMail($emailParams);
osc_add_flash_ok_message('Email sent', 'admin');
header("Location:" . osc_admin_base_url(true) . '?page=items');
}
exit();
break;
}
}
}
osc_add_hook('before_admin_html', 'cbk_r_resend_email_action');
function cbk_r_insert_resend_table_link($row, $aRow) {
if ($aRow['fk_i_user_id'] == '') {
$row['red'] = '<a href="' . osc_admin_base_url(true) . '?page=items&action=resend_edit_email&id=' . $aRow['pk_i_id'] . '">Resend email</a>';
}
return $row;
}
osc_add_filter("actions_manage_items", "cbk_r_insert_resend_table_link");
Re: Send again edit/delete link to manage ads for non register users
on :March 2, 2023, 2:55 pm #686
Thanks for the code - it works, but this option (send mail with link to edit/delete ad) is only available to admin, and only admin can resend the code, provided someone asks him to do so.
I wanted this option to be available in every ad, so that the user would send this cde by email himself. Hence the idea to use the "send to friend / share" mechanism.
Based on your solution i reworked "send to friend" mechanizm and now anyone can click on the "send me the edit/delete link again" link. Mail is sent to the owner of the ad and the admin does not have to deal with it anymore.
If someone wants something like this, unfortunately, you have to edit the 'oc-includes' files, that is, in the "osclass engine" :/
Maybe there is some other better way, based on the @calinbehtuk solution, by adding some functions in the 'Function' file, but I do not know how to do it.