Custom cron job to evaluate group membership for members

fredrikse

Active member
Hi,

I believe I'm in need of a custom cron job that can evaluate group membership and based on that do certain things in the XenForo database.

Short background information
At the very beginning RagTek helped me out creating a function that would be able to control the use of the "Watch thread" function (http://xenforo.com/community/threads/whatch-thread-permission-not-working.38717/#post-433387) which is incorporated in XenForo. The reason for me wanting this is that I want to be able to offer this specific function in a premium membership.

We started out by hiding "Watch thread" in the thread itself based on the membership of a certain group. That was that. After a while I realized there were more things related to this function that we had not taken care of. With help of TMS I have managed to pin point all visible links related to it. But my great head ache now is the part in the thread create view where the user has options to watch the thread which is about to be created. Once again I used TMS to hide the options and to set values to "0" instead of "1" so that the checkboxes were unchecked. But the threads kept on being watched upon creation. I didn't understand why at the beginning. But I kept on troubleshooting and tried to remove these options from the user settings page. Then there were no "watch thread" anymore because this time the values were actually saved to the database. That's why it didn't work before by just unchecking the boxes "visually".

How to solve this
To solve this I think a cron job would be the best way to go. I want to make a check and filter out all members that are not member of this premium group. For those members I want to execute an SQL UPDATE query to set the "correct" settings, for instance regarding "watch thread". By doing this I will only have to take care of the visible parts of this function in the differents views.

Is this easy to solve? How long time would it take to accomplish?
 
As i wrote in the conversation (1 month ago) , this is IMO a xenforo bug, because xenforo isn't checking the permissions in the template and that's why it's showing the watch thread feature to all registered users.... so the method "canWatchThread" doesn't make sense ATM because it's not used everywhere.....

And i can't include every small xenforo bugfix into my addons because several small changes would break some other xenforo features again...
XenForo Devs should start to fix the bugs...


so you'll need to change in post_edit & thread_create template:
<xen:if is="{$visitor.user_id}">
<fieldset>
<dl class="ctrlUnit">
<dt>{xen:phrase options}:</dt>
<dd><ul>
<li><xen:include template="helper_thread_watch_input" /></li>
</ul></dd>
</dl>
</fieldset>
</xen:if>


the fix would be to include this check
Code:
'canWatchThread' => $threadModel->canWatchThread($thread, $forum)
 
I have done all the workarounds that you wrote to me about. The most of it I have modified with TMS apart from that fix which had to be edited directly in the source file. The big issue for me now is that I can't control the user settings which is presented when a user is about to create a thread. It does not matter that I hide those checkboxes. Believe me, I have tried. It seems like the create thread process takes these settings from the database (see picture) when the thread is created. That's why I want a cron job the restore the settings to a baseline which is valid for all members that does not have a premium membership, which this "watch thread" function will be a part of.

db.webp
 
i hope it's easy to fix:D
I do too :) Thanks!

Regarding the cron job I still think it would be useful regardless if it will be a part of the solution for the "watch thread" function. Let's say that members sign up for the premium membership for one month. When that month is over they will not be a member of that specific group which is linked to the premium membership. But they will STILL have the correct settings for the "watch thread" function to work which mean that they still will get notices in XenForo and to their e-mail. That's why I want to be able to adjust the settings to a predefined baseline for non premium members.
 
Hm, probably the best way would be to change the "default_watch_state" while the user downgrade instead of the cronjob
 
Back
Top Bottom