vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   "Receive Email from Administrators": Which members have set this to "no"? (https://vborg.vbsupport.ru/showthread.php?t=293542)

licensinglinks 01-03-2013 06:46 AM

"Receive Email from Administrators": Which members have set this to "no"?
 
Is there a way of getting a list of usernames who have set it to "no"?

Similarly I would like to know who has selected "Don't receive Email Notification of new Private Messages"

Thanks.

--------------- Added [DATE]1357252509[/DATE] at [TIME]1357252509[/TIME] ---------------

anyone any thoughts?

licensinglinks 01-04-2013 12:49 PM

anyone got any ideas?

snakes1100 01-04-2013 12:51 PM

You would have to create a custom script or use a query directly thru mysql or phpmyadmin.

licensinglinks 01-04-2013 01:12 PM

Yes I know that. Does anyone know what query I would need to run in phpmyadmin?

Brandon Sheley 01-04-2013 02:27 PM

I'd check the user table and see what field that is, then something like
select * from user where admin_emails = no

Simon Lloyd 01-04-2013 03:02 PM

You'd need to know which option in the user table is for recieve admin emails and then get the matches like this
PHP Code:

SELECT 
FROM `user`
WHERE substr(`options`, 51) = '1' 

So this one says show all the people who have the option set for 1 at position 5 in the string of options, so maybe in phpmyadmin the options column looks like 432516780 as you can see in this example position 5 shows 1 so it would be a match.

I dont know what the criteria is for creating the options list or how they arrive at the figures, if i did i could help further :)

--------------- Added [DATE]1357315487[/DATE] at [TIME]1357315487[/TIME] ---------------

Quote:

Originally Posted by Brandon Sheley (Post 2394658)
I'd check the user table and see what field that is, then something like
select * from user where admin_emails = no

Unfortunately that column doesn't exist :(

kh99 01-04-2013 03:19 PM

It would be:
Code:

SELECT username FROM user WHERE options & 16 = 0

Simon Lloyd 01-04-2013 03:27 PM

Hi Kevin could you possibly explain the & 16 =0 obviously it works but i don't know why? :)

kh99 01-04-2013 03:39 PM

It's kind of like what you said, only for your method to work the value would have to be a string, with the number represented in binary. The & operator is kind of like treating an integer field as if it were a binary string, and checking only one character out of it. '&' means 'bitwise and', and 16 is 10000 in binary, so it's checking the 5th bit from the right. When you '&' the values, you'll get either 16 or 0, depending on whether or not that bit is set, so then you just have check for whether or not the result is 0.

I hope that makes some sense. Maybe this is better: http://en.wikipedia.org/wiki/Mask_%28computing%29

Simon Lloyd 01-04-2013 03:44 PM

It makes perfect sense, i had the right idea but just not the skill to execute it properly! - thanks for the explanation and it's something i'll add to my toolchest for future :)

John Lester 01-04-2013 05:31 PM

Quote:

Originally Posted by kh99 (Post 2394667)
It would be:
Code:

SELECT username FROM user WHERE options & 16 = 0

For the "Do not receive email notification upon new pms" change the 16 in the above code to 4096

WorldCraft 01-05-2013 08:29 AM

How do you know which option goes to which bit position value?

kh99 01-05-2013 12:46 PM

Quote:

Originally Posted by WorldCraft (Post 2394852)
How do you know which option goes to which bit position value?

The actual values are defined in the file includes/xml/bitfield_vbulletin.xml . The bits used in the user table options field are in a group named "useroptions". But you'd really have to look at the code to figure out which value does what (well, for some you might be able to guess).

Another way you can find out some of the values is to go (in the admicp) to Maintenance > Execute SQL Query, and look at the Automatic Query list. There are automatic queries to set all users to receive admin emails or not, so if you select one of those queries you can see how it's changing the database. If you choose "Yes - Receive Admin Emails" and press continue, you'll see this:
Code:

UPDATE user SET options = options + 16 WHERE NOT (options & 16)

and you can tell from that that the value you want for that option is 16. (BTW, you can choose a query from the Automatic Query menu and press Continue, and it will show you the query but not execute it unless you press Continue again).

WorldCraft 01-06-2013 08:29 AM

Thanks Kevin, great information. :)

licensinglinks 01-06-2013 10:21 AM

Thanks all for your help.

Quote:

Originally Posted by kh99 (Post 2394667)
It would be:
Code:

SELECT username FROM user WHERE options & 16 = 0

Quote:

Originally Posted by John Lester (Post 2394708)
For the "Do not receive email notification upon new pms" change the 16 in the above code to 4096

This all worked perfectly. Cheers!

Now I have another question that's related to this. Basically I have set up some custom profile buttons for members' communication preferences. They are simple Yes/No radio buttons:


(1) Newsletter subscription (monthly): Yes/No
(2) Digest subscription (weekly): Yes/No
(3) Promotional email subscription (monthly): Yes/No


I have set every member to "Yes" for both, but I want to change everyone who doesn't receive admin emails to "No" for (1), (2) and (3) and everyone who doesn't want PM notification to "No" for (2). This is to ensure I don't annoy anyone with unwanted emails.

Can anyone please advise what queries I would need to run to do this?

Simon Lloyd 01-06-2013 12:13 PM

Custom profile fields are are in the userfield table, to alter those its something like
PHP Code:

UPDATE`userfield`SET`fieldX`='No' WHERE`fieldX` =Yes

so change fieldX to your field number like field10. Dont forget to change the userfield for how it is in your database, if you used a prefix "vb_" then it would be vb_userfield, if you used a prefix say "xy" then it would look like this xyuserfield.

licensinglinks 01-06-2013 04:53 PM

So if, for example, I want to change people everyone who doesn't receive admin emails to "No" for newsletter subscription it would be:

PHP Code:

UPDATE`userfield`SET`field15`='No' WHERE`field16` =Yes

(Custom profile field for newsletter subscription (Yes/No) is field15)

Something doesn't seem right about the above code. Shouldn't field 16 =0 ?

kh99 01-06-2013 05:24 PM

You'd need something like:
Code:

UPDATE user LEFT JOIN userfield USING(userid)
  SET fieldX='No', fieldY='No', fieldZ='No'
  WHERE (options & 16) = 0


and
Code:

UPDATE user LEFT JOIN userfield USING(userid)
  SET fieldY='No'
  WHERE (options & 4096) = 0


of course you need to set X, Y, and Z to the actual ids.


All times are GMT. The time now is 03:28 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01382 seconds
  • Memory Usage 1,763KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (3)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete