solved Turn off notifications for everyone

White Agency
White Agency
@white-agency
9 years ago
204 posts
As part of our user testing before we go live, we need to turn off notifications for everyone so that we can comment/like/rate things without emails being sent out and users finding out where the test site is.

We'd like to turn off notifications for everyone then re-enable for those users doing the testing so we can test the emails are working as we would like them to.
updated by @white-agency: 07/17/15 01:13:55AM
michael
@michael
9 years ago
7,714 posts
Probably the easiest way would be:
ACP -> MODULES -> COMMUNICATION -> EMAIL SUPPORT -> ACTIVE EMAIL SYSTEM -> "log sent email to debug log"

So it goes to the database instead of sending out.
White Agency
White Agency
@white-agency
9 years ago
204 posts
Thanks Michael but we need the emails turned on whilst we do the testing.

I've already had to change the domain 3 times because of emails being sent when things have been liked/rated etc with the result the user who receives the notification then visiting the site and trying to retrieve their password !!

We just need turn off notifications for everyone and then re-enable for those doing the testing so that emails don't go those who are not doing the testing.
Strumelia
Strumelia
@strumelia
9 years ago
3,603 posts
I had this same issue of members get notifications (unbeknownst to me) before the site was ready, and following the links in the email, to my site. I had to set my JR site into maintentence mode to keep them out, but it's tricky posting content while testing, and knowing the members may receive real life notifications if you post something in the wrong place while testing the site.


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
michael
@michael
9 years ago
7,714 posts
The function responsible for sending user notifications is jrUser_notify()

Its in:
/modules/jrUser/include.php around line 1010 ish. It looks like this:
/**
 * Notify a User about a specific event
 * @param mixed $to_user_id User ID to send notification to (int or array of int)
 * @param int $from_user_id User ID notification is from
 * @param string $module Module that has registered the notification event
 * @param string $event Event Name
 * @param string $subject Subject of notification
 * @param string $message Message of notification
 * @return bool
 */
function jrUser_notify($to_user_id, $from_user_id, $module, $event, $subject, $message)
{ global $_conf; // Make sure we're not recursive if (jrCore_get_flag('jruser_notify_is_running')) { return true; } jrCore_set_flag('jruser_notify_is_running', 1); // Make sure module has registered $_tmp = jrCore_get_registered_module_features('jrUser', 'notification'); if (!isset($_tmp[$module][$event])) { //.........

There is no setting to turn off the notifications system, but the goal is to not have that function fire.

Its used in many many modules, so the best way is just to let it fire, but not allow it to complete.

If you alter the code to add
function jrUser_notify($to_user_id, $from_user_id, $module, $event, $subject, $message)
{ return true;

Right after the opening bracket and leave the rest in tact that would do what your after.

But probably a safer way is to not alter that and instead go into:

/data/config/config.php and add this line to the end of the file:
jrCore_set_flag('jruser_notify_is_running', 1);

Which is already contained in the code so you won't need to alter any module files.

The full config.php file will look something like this after that:
<?php
$_conf['jrCore_db_host'] = 'localhost';
$_conf['jrCore_db_port'] = '????';
$_conf['jrCore_db_name'] = '???';
$_conf['jrCore_db_user'] = '????';
$_conf['jrCore_db_pass'] = '????';
$_conf['jrCore_base_url'] = 'http://????.com';

jrCore_set_flag('jruser_notify_is_running', 1);

That will also tell jrUser_notify() not to run. Just remember to take it out again when you want to turn notifications back on.
Strumelia
Strumelia
@strumelia
9 years ago
3,603 posts
" But probably a safer way is to not alter that and instead go into:
/data/config/config.php and add this line to the end of the file: "

Michael, can I get to that php file through my ACP, or...where exactly pleasedo I find it to change and then change back that code?
I'm after the exact same thing as WhiteAgency...just about to send testing invites to a handful of testers to log in and check things before sending out my thousands of invites. Can't have hundreds of members getting notifications and banging on the door and emailing me all confused while the testers are posting things for a day before going live... =8-\



--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015

updated by @strumelia: 06/12/15 07:53:29PM
michael
@michael
9 years ago
7,714 posts
not via the ACP, but you can via SFTP.

Your SFTP details can be got from:
https://www.jamroom.net/strumelia/

* HOSTING -> SERVER DASHBOARD -> SERVER SETTINGS

You'll see something like:
SFTP Login: something • Rfx3szNPJuBaSbjhvuCjcNJId3GAjB

That is your username / password for logging in via SFTP

When you login you will see the sites on the server, locate the one your after (if you have more than one site on your server), go into that folder and you'll see the standard jamroom structure:
/data
/modules
/skins

the config is in:
/data/config/config.php

That's the file your after.
Strumelia
Strumelia
@strumelia
9 years ago
3,603 posts
I should have mentioned that I know how to get on my server using Filezilla- sorry.

"the config is in:
/data/config/config.php
That's the file your after."

yeah that was it, thank you.
I'm working with Paul now on this.
My new JR home should be going live within the next day or so! So exciting! =8-D

I'm bookmarking this useful thread in case I need to temporarily turn off all member notifications for some reason in the future, on my own.


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
White Agency
White Agency
@white-agency
9 years ago
204 posts
Thanks Michael.

Now we know where the code is we can mod the it for testing so that only certain user_id's can receive emails.
michael
@michael
9 years ago
7,714 posts
no. If you want to do that, you'd need to build a module.

If that was the question from the beginning, then "Turn off notifications for everyone" is the wrong title. ;)

There is an event to listen for:
'notify_user'

Your module could pick up on that event:

"events and listeners"
https://www.jamroom.net/the-jamroom-network/documentation/development/1011/events-and-listeners

and check that the 'to_user_id' is within an allowed list and only continue if it is.

Or else listen for the 'create_queue_entry' event and un-set the $_data if the 'queue_name' is 'send_email'

That would do it too. Probably the second is the way to go.

Tags