• Resolved joropress

    (@joropress)


    1. Is there a way to convert advert-tag into a class, in order to attach a badge to the ads with this tag, by using it as a class?

    2. How to automatically add a defined tag, if an ad is checked as a VIP/Featured?

Viewing 15 replies - 16 through 30 (of 30 total)
  • Thread Starter joropress

    (@joropress)

    Hi,
    After changing the line I don’t see a fatal error in debug mode like before.
    There are 2 instances (on 300 and 378 row) of this line in my-site\wp-content\plugins\wpadverts\addons\payments\includes\admin-pages.php should I change both?

    The problem still occurs. On Ad publish everything works fine and the tag is added automatically, then on Ad Expire the tag is removed automatically but on Ad Renewal – the Ad gets renewed but the tag is not added again.

    Plugin Author Greg Winiarski

    (@gwin)

    You can change the code in both places.

    As for the code itself i am checking it right now and it seems to be working fine for me. You can try adding some debug code to see if the code is executed at all.

    Thread Starter joropress

    (@joropress)

    Hi,
    I have some small errors in my site but they really don’t affect in this case.
    I know this for sure because during the debugging process I temporary cleared all the errors by not using some code snippets in order to see if this solves the problem but it doesn’t. The tag still do not add on renewal.

    I noticed that the tag is not added on renewal initially but is being added if for example I put the renewed Ad to the status of “pending” again and after that goes back to “completed” manually. So by thinking out of the box I think that if there is a code that could add this second turning between “pending” and “completed” status this would solve my problem. Do you know such a code?

    Lets summarize – it perfectly works on free Ads turned to paid and on paid Ads renewed before they have expired. It doesn’t work only if an expired Ad is renewed.

    By the way – if I change it on both places the previous error occurs but if changed only to the second place (378 line) there is no more error message. So I use it that way.

    • This reply was modified 6 years, 5 months ago by joropress.
    • This reply was modified 6 years, 5 months ago by joropress.
    Plugin Author Greg Winiarski

    (@gwin)

    What payment method do you use to accept the payments?

    Thread Starter joropress

    (@joropress)

    The standard Bank Transfer method.

    Plugin Author Greg Winiarski

    (@gwin)

    Ok, i will try that in the middle of next week when i am back in the office.

    Sorry, for the delay.

    Thread Starter joropress

    (@joropress)

    Hi,
    is there any progress?

    Plugin Author Greg Winiarski

    (@gwin)

    It seems that on renewal the tag is first being added and then removed by expired_advert action.

    The solution would be to run the tag_an_advert function with lower priority, you can do that by changing line

    
    add_action("adverts_payment_completed", "tag_an_advert" );
    

    to

    
    add_action("adverts_payment_completed", "tag_an_advert", 20 );
    

    If this will not help try adding after

    
    wp_set_object_terms( $object_id, "vip", "post_tag", true );
    

    this line

    
    remove_action( 'expired_advert', 'on_expired_advert' );
    
    Thread Starter joropress

    (@joropress)

    Brilliant! That really solved the problem! Thank you for the time spent on this topic!
    But I realized that there is one more thing that needs some attention. I need to uncheck the Featured Ads checkbox that stays checked when a paid Ad (after expiration) for some reason is renewed as a Free Ad. Otherwise the Free Ad would still look like a Paid one with the only difference that will not be shown in the Carousel Slider due to the removed Vip tag.
    Is there a way to do this final thing?

    Plugin Author Greg Winiarski

    (@gwin)

    I understand you want to un-feature the Ad when it expires? If so then inside the on_expired_advert() function add the code below

    
    wp_update_post( array( 
      "ID" => $post_id,
      "menu_order" => 0
    ) );
    
    Thread Starter joropress

    (@joropress)

    That would do the trick, but it looks like something goes wrong when the code is being executed. The browser-site-tab just stops working for a couple of minutes. The whole site stops working for this period. No matter the browser – tried with Firefox, IE and Chrome. Same result. There are no additional errors when debugging.
    It looks like it works because after some time when I run again the browser the checkbox is unchecked. What could cause this time delay?

    Plugin Author Greg Winiarski

    (@gwin)

    Most likely the wp_update_post() is going into an infinite loop due to all the filters used.

    Try updating the menu_order directly in the database with this code instead

    
    global $wpdb;
    $wpdb->update( 
      $wpdb->posts, 
      array( 'menu_order' => 1 ),
      array( 'ID' => $post_id ),
      array( '%d' ),
      array( '%d' )
    );
    
    Thread Starter joropress

    (@joropress)

    I needed to change this line:

    array( 'menu_order' => 1 ),

    with this:

    array( 'menu_order' => 0 ),

    and it worked perfect!

    Thank you Greg for everything!

    Problem solved! And this is my review ??

    Plugin Author Greg Winiarski

    (@gwin)

    Ok great, and thanks for the awesome review ??

    Thread Starter joropress

    (@joropress)

    One last thing – I forgot to mark it as RESOLVED and now this is going to be fixed : )

Viewing 15 replies - 16 through 30 (of 30 total)
  • The topic ‘Tags and Classes’ is closed to new replies.