BuddyDev

Search

Can we remove featured members automatically?

  • Participant
    Level: Enlightened
    Posts: 77
    Stephanie on #53040

    Hello

    I see that you have a plugin for featuring Buddypress members and that you have a code (https://github.com/buddydev/bpfm-woocommerce-addon) to make an option in Woocommerce so that when a user buys a product marked with that option in Woocommerce, they become featured automatically on the front end.

    Is there a way to remove them from being featured automatically too, for example so that the user will be featured for 30 days and after 30 days they will no longer be featured and will need to purchase a new “product” to be featured again?

    Thank you

  • Keymaster
    (BuddyDev Team)
    Posts: 24879
    Brajesh Singh on #53043

    Hi Stephaine,
    Thank you for the question.

    here is a plugin that does it.
    https://github.com/buddydev/bp-featured-member-expirable-membership

    Please change days from 7 to 30 in this.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 77
    Stephanie on #55173

    Hello,

    I am trying to change the duration of the featured member validity period in the expirable membership code mentioned above. I noted you said “Please change days from 7 to 30 in this.”.

    I would like to check something, because when I tried changing the number of days to 1 (so that I don’t have to wait a long time to see if worked), it didn’t work.

    When I looked at the code, on line 59 the comment says Setup hourly cronjob to remove featured members and on line 64 it says wp_schedule_event( time(), 'hourly', 'bp_fma_remove_featured' );. Note that they both say “hourly”. As I understand it, cron jobs that run hourly is more accurate to the day than cron jobs that run daily since it would run 24 times in a day and check for expiration 24 times, so maybe this isn’t an error.

    But then on line 76 it says “How much time to expire.” and the time is in seconds, not days or hours, as written on line 81 where it says DAY_IN_SECONDS.

    So my question is this: my featured members are not expiring – I put 1 for 1 day on line 81 where it originally says return 7 * DAY_IN_SECONDS;.

    What am I doing wrong, should it say “DAY_IN_HOURS” instead, or am I supposed to write the duration of the number of days in seconds format (ie “86400” for 1 day) so it looks like “return 86400 * DAY_IN_SECONDS;”?

    Thank you
    Stephanie

    • This reply was modified 3 weeks, 4 days ago by Stephanie. Reason: Edit for clarity
  • Keymaster
    (BuddyDev Team)
    Posts: 24879
    Brajesh Singh on #55181

    Hi Stephine,

    1. Please check the cron jobs are schedule using any cron debug plugin
    2. ‘hourly’ is correct. It says the job should run hourly(the function that checks for the removal will run hourly)
    .

    3. The returned value from get_interval should be duration in seconds. So 1 day is DAY_IN_SECONDS (or 1*DAY_IN_SECONDS if that helps understand it);

    Hope that helps.

  • Participant
    Level: Enlightened
    Posts: 77
    Stephanie on #55188

    Hello Brajesh,

    Thank you for the explanation, I understand it now. I will try a cron job debugger and see how I go.

  • Participant
    Level: Enlightened
    Posts: 77
    Stephanie on #55191

    I installed and activated “Advanced Cron Manager – debug & control” and it has a list of jobs scheduled, but I can’t find or identify which one would be the job scheduled to automatically remove the featured member. For example, I don’t know if it is the “woocommerce_tracker_send_event” since featured membership can be purchased via Woocommerce, or if it is “puc_cron_check_updates-buddypress-member-type” cause the name is about buddypress member type.

  • Keymaster
    (BuddyDev Team)
    Posts: 24879
    Brajesh Singh on #55202

    Please deactivate this plugin(Featured Member Expiration) and reactive. Then check for the cron jobs. The job name should be ‘bp_fma_remove_featured’

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 77
    Stephanie on #55207

    Hi Brajesh,

    I added the expiration feature by code snippet from the github link mentioned above, I didn’t install it as a plugin. I deactivated the code, then reactivated the code, purged the cache, and looked at the list of cron jobs, and “bp_fma_remove_featured” was not there, nothing similar in wording to that was there either.

    Thanks
    Stephanie

  • Keymaster
    (BuddyDev Team)
    Posts: 24879
    Brajesh Singh on #55220

    Hi Stephanie,
    Thank you.
    That’s the problem. If you did not install it as plugin, the activation routine that registered cron will not be triggered. It must be installed as a plugin and activated for the cron job to be registered/running.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 77
    Stephanie on #55228

    Hi Brajesh,

    Sorry if this is a stupid question, but I downloaded the php file from Github (when downloaded, it is only a PHP format) and put it in a zipped folder, then uploaded it in my dashboard in Plugins -> Add New. It was uploaded successfully but could not be activated. When I tried to activate it, there was an error message saying “Plugin could not be activated because it triggered a fatal error.”

    So, since I can’t install it, I can’t proceed with other tests.
    Stephanie

You must be logged in to reply to this topic.

This topic is: not resolved