Enable Forum topic activity notification on new member

Post

Posted
Rating:
#5327 (In Topic #1214)
Avatar
Standard member
supertramp4 is in the usergroup ‘Fan in action’
Hi
Could anyone give me some php coding snipits as to how at automatically enable the "Forum topic activity" email notification setting when a new member joins.

Currently its disabled but the nature of our group and the skill set means that is proving changing for quite a few peopleto change it themselves. and this would really help everyone involved.

Many Thanks
Chris
Online now: No Back to the top

Post

Posted
Rating:
#5330
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Hi,

I didn't test it, but try this sources_custom/hooks/systems/upon_query/auto_notifications.php:

Code

<?php

class Hook_upon_query_auto_notifications
{
    public function run_post($ob, $query, $max, $start, $fail_ok, $get_insert_id, $ret)
    {
        if (isset($GLOBALS['FORUM_DB']) && strpos($query, 'INTO ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members') !== false) {
            require_code('notifications');
            enable_notifications('cns_topic', null, $ret);
        }
    }
}

Last edit: by Chris Graham



Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#5331
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
I imagine you could also do a pure MySQL solution, using triggers:
MySQL :: MySQL 5.7 Reference Manual :: 23.3.1 Trigger Syntax and Examples


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#5334
Avatar
Standard member
supertramp4 is in the usergroup ‘Fan in action’
Hi Chris,
Your auto_notifications.php code worked first time 
I would have never worked out to put it in that directory !!

Sincere thanks
Chris
 
Online now: No Back to the top

Post

Posted
Rating:
#5566
Avatar
Standard member
supertramp4 is in the usergroup ‘Fan in action’
Hi.
Although the hook is working as intended there is a slight problem that new members who have not yet been validated by staff are receiving notifications which should not yet be receiving (until they are validated)

How and where in notifications.php can I check to only send notifications to members who are validated ?
Chris
Online now: No Back to the top

Post

Posted
Rating:
#5568
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#5584
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
I was going through tests for the next patch release and found this fix was failing.
I've now completely rewritten the _all_members_who_have_enabled method, as it's complexity density had gotten too high to understand it.

Please grab the full function from:
composr/notifications.php at master · ocproducts/composr · GitHub
And put it into your version of the file.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#5646
Avatar
Standard member
supertramp4 is in the usergroup ‘Fan in action’
HI Chris,
sorry for the delay, but have just tried the new code from git, and we have a constant problem when people try to set their password from their profile. Here's an example error, generated from the sources_custom/notifications.php

Unfortunately a query has failed [SELECT m.id AS l_member_id,l_setting FROM cms_f_members m LEFT JOIN cms_notifications_enabled l ON m.id=l.l_member_id AND l_notification_code='cns_password_changed' AND l_code_category='' WHERE 1=1 AND ( OR m.id=743) AND m_validated_email_confirm_code='' AND m_validated=1 AND m.id<>1 AND l_setting IS NULL OR l_setting<>0 LIMIT 0,300] [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OR m.id=743) AND m_validated_email_confirm_code='' AND m_validated=1 AND m.id<>1' at line 1] (version: 10.custom, PHP version: 7.1.26, URL: /c10/index.php?page=members&type=view&id=743)

Thanks
Chris
Online now: No Back to the top

Post

Posted
Rating:
#5649
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Hi,

I suspect you didn't use the very latest code. There were a couple of fixes I had to make unfortunately after my changes…
Fixed nasty notifications bug · ocproducts/composr@a608c52 · GitHub
https://github.com/ocproducts/composr/commit/567fc9b4cefb3532203dec653dca7e44e5a7e436#diff-da9c5b50898a13f5f3a985360ba719bd

Maybe you'd already downloaded the file before I made the changes or something.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#5650
Avatar
Standard member
supertramp4 is in the usergroup ‘Fan in action’
Hi Chris,
I have just added the changed lines, and after changing the password on an account  that has just sent an e-mail notification saying their password has been changed to EVERYONE ! - Big problem

I have been logging the resulting SQL, and this is what it generated

SELECT m.id AS l_member_id,l_setting FROM cms_f_members m LEFT JOIN cms_notifications_enabled l ON m.id=l.l_member_id AND l_notification_code='cns_password_changed' AND l_code_category='' WHERE 1=1 AND (m.id=743) AND m_validated_email_confirm_code='' AND m_validated=1 AND m.id<>1 AND l_setting IS NULL OR l_setting<>0
Online now: No Back to the top

Post

Posted
Rating:
#5651
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
:(. You're definitely sure this isn't a bug that happened before those changes? Because that query looks correct, it's filtering to only one member ID.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#5652
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Wait no, it's illustrating the bug fixed in:
Fixed nasty notifications bug · ocproducts/composr@a608c52 · GitHub

Perhaps you didn't see I posted 2 links?


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#5653
Avatar
Standard member
supertramp4 is in the usergroup ‘Fan in action’
Hi Chris,
I have just run the query in phpmyadmin, and it returned 191 records,

phpmyadmin :

 Showing rows 25 - 49 (191 total, Query took 0.0029 seconds.)
SELECT m.id AS l_member_id,l_setting FROM cms_f_members m LEFT JOIN cms_notifications_enabled l ON m.id=l.l_member_id AND l_notification_code='cns_password_changed' AND l_code_category='' WHERE 1=1 AND (m.id=743) AND m_validated_email_confirm_code='' AND m_validated=1 AND m.id<>1 AND l_setting IS NULL OR l_setting<>0

l_member_id , l_setting
535 2
537 2
542 2
543 2
544 2
548 2
550 2
….



edit - let me checkout the other github code change.....

Last edit: by supertramp4

Online now: No Back to the top

Post

Posted
Rating:
#5654
Avatar
Standard member
supertramp4 is in the usergroup ‘Fan in action’
Hi Chris,
Thanks, I had missed the other git change.
That's sorted now and seems to be working.

Many Thanks
Chris
Online now: No Back to the top

Post

Posted
Rating:
#5655
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Great. This was an embarrassing bug honestly, and I'm sorry it hit you. What a difference a pair of brackets can make.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

John Connor, MVLipwig, SoccerDad, KingBast, Salman

Forum statistics: Birthdays:
Back to Top