• Resolved Houdini

    (@romariokg)


    I want to try to change the “Renew” function. I need it so that when you click on Renew, the publication date of an expired ad will be updated to the current day. I can’t find the code snippet that does this function, could you please guide me?

    Write the path to the file function, please, or help me do this.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    The renew code available in following location plugins/classified-listing/app/Controllers/Ajax/PublicUser.php

    There have an action hook after renew a listing, you can try to change the publish date of that listing using the action https://prnt.sc/_XdclOx28_fm

    Thank you

    Thread Starter Houdini

    (@romariokg)

    Hello! Great! I did it. you need to replace the code from line 311 to 318 with the following:

    	$post_arg = [
    'ID' => $listing->get_id(),
    'post_status' => 'publish',
    'post_date' => current_time('mysql'), // Update publication date to the current one
    'post_date_gmt' => get_gmt_from_date(current_time('mysql')), //Update date in GMT
    ];
    $updatedListingId = wp_update_post($post_arg);
    if (is_wp_error($updatedListingId)) {
    return $updatedListingId;
    }

    But for some reason, after clicking the Refresh button, I get the message “Your listing has been updated” and I need to refresh the page to see the new date on the listing. Don’t know how to fix it?

    Ali Akbar, I think you need to change this function in future updates, as it will be logical and correct if it works this way! This works like this on all ad sites I know!

    Also on other sites, activation and renewal of an expired advertisement with updating the publication date is paid! It would be good if you thought about this feature! Thanks for your help!

    Please also check ticket ID# 88895. I would like to speak with you personally about this.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    Thank you for your suggestion, will discuss about it.

    Thread Starter Houdini

    (@romariokg)

    for some reason after clicking the Refresh button I get a message saying “Your listing has been updated” and I need to refresh the page to see the new entries in the listing. Don’t know how to fix it?

    You had the same problem before with the SoldOut emblem. Our page is my listing.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Thanks for notify, will check it.

    Thread Starter Houdini

    (@romariokg)

    Hi, how can I override the PublicUser.php file ?

    When updating the plugin, I have to constantly edit the code to the above.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    Sorry, you can not override the core file directly. There have available action and filter hook, modify the functionalities using hook.

    If you need any specific modification but there not available hook, let us know to add hook. So that, you can modify data using hook.

    Thank you

    Thread Starter Houdini

    (@romariokg)

    Hello Ali Akbar. Could you help me figure this out, or just make this change in your plugin. it will be correct and logical.

    How can I change this functionality using a hook, I didn’t succeed.

    How can I replace the function or part of the code that is given above.?

    Every time I have to edit the code when updating the plugin.

    • This reply was modified 2 months, 1 week ago by Houdini.
    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    We discussed about it. We will not change main created/publish date for renew listing. It’s needed for future use to get actual statistics of this listing when it’s created and when expired then it’s renew or not and so on.

    We have hook to change it which discussed before. If you need any help further to manage it for you, you can create support ticket from our site.

    Thank you

    Thread Starter Houdini

    (@romariokg)

    Hello Ali Akbar! I created a support ticket regarding this issue, but your colleagues could not help me. I thought maybe you could add this feature to the settings so that you can activate it using a checkbox?

    Do this: Update the announcement date upon renewal: Checkbox.

    Most likely I’m not the only one who needs this function.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    Could you share the ticket ID?

    Thank you

    Thread Starter Houdini

    (@romariokg)

    Ticket Received – Update Renew function in PublicUser.php file. ID# 92064

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    Try following code –

    add_action( 'rtcl_after_renew_listing', function ( $listing, $vStore, $wp_error ) {
    if ( $wp_error->has_errors() ) {
    return;
    }
    $post_arg = [
    'ID' => $listing->get_id(),
    'post_date' => current_time( 'mysql' ), // Current local time
    'post_date_gmt' => current_time( 'mysql', 1 ), // Current GMT time
    ];
    wp_update_post( $post_arg );
    }, 20, 3 );

    I tested, it works.

    Thank you

    Thread Starter Houdini

    (@romariokg)

    Hi. Thanks, it seems to work!

    Thread Starter Houdini

    (@romariokg)

    Thanks, it seems to work!

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.