Quote:
Originally Posted by CrazyLady
just a shot in the dark here, but in the "functions_secretadmirer.php" could I replace this
Code:
//
// Send an email if we couldn't send a PM
//
if (!($notifyUser['options'] & $_USEROPTIONS['receivepm'])) {
//
// Get the Email message
//
with this?
Code:
//
// Send an email if we couldn't send a PM
//
if (!($notifyUser['options'] & $_USEROPTIONS['receivepm'] & $vboptions['showemail'] & $vboptions['adminemail'])) {
//
// Get the Email message
//
all new to this stuff, but my attempt here is to check if the user has enabled both "Receive Email from Administrators" and "receive emails from other members". if not, no email is sent.
am I close? :ermm:
|
Nice try but that wouldn't work.
There are two bitflag fields that contain the bits that indicate whether a user allows emails on those two criteria.
Those values are defined in includes/init.php
Namely they are these rows in the $_USEROPTIONS array:
'adminemail' => 16,
'showemail' => 256,
And the sum of the bits is the bitflag in $notifyUser['options'].
You would perform the logic roughly like this, but beware, the & is not doing what you think it is... you might want to look at the PHP manual regarding bitwise operators.
Code:
//
// Send an email if we couldn't send a PM
//
if (!($notifyUser['options'] & $_USEROPTIONS['receivepm']) &&
($notifyUser['options'] & $_USEROPTIONS['showemail']) &&
($notifyUser['options'] & $_USEROPTIONS['adminemail'])) {
//
// Get the Email message
//
Which basically checks that they cannot already receive PM's, but that they ARE able to receive emails from both other users and admins.
Bitwise operators can be daunting when you first encounter them, so let me show you very quickly how they work.
Basically you take numbers that are of the power of 2.
1
2
4
8
16
32
If we presumed that they represented letters of the alphabet:
1 = A
2 = B
4 = C
8 = D
16 = E
32 = F
Then we could build a value that encapsulated which of those letters we wanted to store.
Example, we want to store options A and C... so it's 1 + 5 = 6.
To store A, D, F it is 1 + 8 +32 = 41.
Given any number you simply subtract the largest value you can to determine your options:
41 - 32 (F) = 9
9 - 8 (D) = 1
1 - 1 (A) = 0
So we know that 41 included the values for F, D and A.
The options field basically stores a bitflag number like that, and the plain & in the logic is not the same as &&, but is a bitwise operator that indicates whether the bitflag contains the desired bits.
So the example above should do it for you