Disable default Email notifications

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6518
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Disable default Email notifications

Post by thecoalman »

Open includes/functions_user.php and on line 372 comment out or delete these lines.

Code: Select all

	if ($notifications_data === null)
	{
		$notifications_data = array(
			array(
				'item_type'	=> 'notification.type.post',
				'method'	=> 'notification.method.email',
			),
			array(
				'item_type'	=> 'notification.type.topic',
				'method'	=> 'notification.method.email',
			),
		);
	}
Optionally you create two boolean custom profile fields. One for topic notifications and one for PM's, field identification should be topic_notify and pm_notify. "Publicly display profile field:" set to no, Under visibility options only check "Display on registration screen:" and "Hide profile field:". The rest should be self explanatory.

Instead of commenting/deleting the lines above replace with:

Code: Select all

	// Use default notifications settings if notifications_data is not set
	// Mod - Custom fields available on registration to set email notification preferences
	if ($notifications_data === null)
	{
		$notifications_data = array();
		if (isset($cp_data['pf_topic_notify']) && $cp_data['pf_topic_notify'] == 1 )
		{
			$notifications_data[] = array(
				'item_type'	=> 'notification.type.post',
				'method'	=> 'notification.method.email',
			);
			$notifications_data[] = array(
				'item_type'	=> 'notification.type.topic',
				'method'	=> 'notification.method.email',
			);
		}

		if (isset($cp_data['pf_pm_notify'])  && $cp_data['pf_pm_notify'] == 1)
		{
			$notifications_data[] = array(
				'item_type'	=> 'notification.type.pm',
				'method'	=> 'notification.method.email',
			);
		}
	}
The profile fields do not do anything past registration and can be safely deleted at any time in the future if you no longer need them for registration,
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
Joe Kolade
Registered User
Posts: 15
Joined: Fri Apr 14, 2023 8:36 am

Re: Disable default Email notifications

Post by Joe Kolade »

Thanks!

Return to “phpBB Custom Coding”