Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for Monthly Recurrence on Multiple Days of the Week #8

Closed
SpeedyTechie opened this issue Apr 21, 2021 · 9 comments
Closed

Option for Monthly Recurrence on Multiple Days of the Week #8

SpeedyTechie opened this issue Apr 21, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@SpeedyTechie
Copy link

SpeedyTechie commented Apr 21, 2021

I ran into a specific case where I need to set something to recur on the 2nd and 4th Thursday of every month. With the current implementation of the plugin, if I select...

  • Frequency: Monthly
  • Every 1 month
  • Day of the week

...it is only possible to select either the 2nd or the 4th Thursday, but not both. From looking at RRULE itself, it seems that it is indeed possible to do what I'm looking to do, but that the ACF implementation doesn't account for this scenario. Would that be possible to add? Or is there a way to do this that I'm missing?

Thanks again for you work on this plugin and thanks in advance for your help with this snag!

@marcbelletre
Copy link
Owner

Hi Zane,

It is indeed not possible right now because the bysetpos parameter is controlled by a single select field. The RRule accepts multiple values for this parameter so we could replace this field by an input or a checkbox group but I'm afraid it would make the plugin less user-friendly.

In my implementation I have an Event custom post type which contains a "Periods" repeater field with RRule fields as subfields. This way I can handle very specific cases like this by creating two separate recurrences. In this case you could create one recurrence for the 2nd thursday and another one for the 4th thursday. But that requires ACF Pro.

I will try to think of a smart way of handling this. I could also take the opportunity to handle the case when this option has to be something else than first, second, third, fourth or last 🙂

@marcbelletre marcbelletre added the enhancement New feature or request label Apr 21, 2021
@SpeedyTechie
Copy link
Author

Got it - intuitively, I was thinking it would be as simple as changing it from a single select to a multi-select. But is there a reason that wouldn't be a good solution?

And yeah, I did think of using the repeater method you mentioned - if all else fails, that's what I'll have to do.

Thanks!

@marcbelletre
Copy link
Owner

Hi @SpeedyTechie,

Sorry I didn't have much time lately to look into this.

I searched for other RRule generators to find examples of other implementations. It turns out that the two first hits on Google for behave the same way as the ACF RRule Field:

I also found this one which is very less user-friendly but enables multi-selection for the bysetpos parameter:

Changing the single select to a multi-select would actually work but it would not be very nice in terms of design and usability. I may have found an alternative in using the advanced UI that ACF enables for select fields. It uses the select2 jQuery plugin which provides a better UI for multi-select fields.

Capture d’écran 2021-04-25 à 23 10 38

The only thing I am not very happy with is the fact that this plugin automatically reorders values in the dropdown after making a selection. Selected values are pushed down to be bottom of the list and are not put back in original order after unselecting them. So you can end up with a totally random order which is not great in our case:

Capture d’écran 2021-04-25 à 23 26 40

I didn't find any way to fix it, also there is a 6 years old issue for this on their repository which is still unsolved (but there is an open PR).

Anyway I pushed the update on a new branch and I would really appreciate your feedback before merging. Maybe in the meantime I can think about a workaround for the sorting issue 😉

@SpeedyTechie
Copy link
Author

Yeah, so the advanced UI is definitely what I was imagining! That ordering issue is unfortunate. Aside from that though, I think this addresses the issue quite nicely!

@SpeedyTechie
Copy link
Author

Hey @marcbelletre - I have a site launching soon that relies on this plugin, and could really use this feature. Any chance you'll be pushing out this update any time soon? I know the ordering issue is a bit annoying, but in my mind isn't too terrible and is worth it for the added functionality. But if you'd rather hold off until you have a solution, I understand. Thanks!

@marcbelletre
Copy link
Owner

Hey Zane,

Sorry I am a bit busy at the moment and I didn't want to rush on this as it changes a bit how things work. I had to make sure it wouldn't break anything on existing projects.

As I said I was not very happy with the sorting issue so I thought it would be better to find a more convenient solution before making a new release.

I found out that it is also possible to set multiple weekdays so you can set something like the 2nd et 3nd mondays and wednesdays. It is a bit unlikely but it is possible with RRule so I thought I could kill two birds with one stone and solve this as well. So I ended up using two checkboxes groups for both bysetpos and byweekday options as you can see below:

Capture d’écran 2021-04-30 à 00 28 25

In my opinion this option is more satisfying than the first one. Also I took the advantage to make things a bit cleaner in the code because the fields were not named correctly.

I released v1.2 on Github so you can already update the plugin if you're using composer. I will publish to the Wordpress repository later tomorrow 🙂

@SpeedyTechie
Copy link
Author

Looks good! Thanks again for your work on this plugin and for your help with this enhancement!

@SpeedyTechie
Copy link
Author

Hey @marcbelletre - I'm so sorry to bug you about this again, but when should I expect to see v1.2 on the WordPress repo? Thanks!

@marcbelletre
Copy link
Owner

Hey,
Here it is: https://wordpress.org/plugins/acf-rrule-field/ :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants