Aeon
New Member
Posts: 46
inherit
aeonofeternity@gmail.com
196622
0
Mar 26, 2023 22:20:33 GMT -8
Aeon
46
July 2013
eon
|
Post by Aeon on Apr 5, 2015 21:01:52 GMT -8
I'm working on a plugin that will allow staff to select certain membergroups in the plugin settings, then have the plugin show a random member from those groups on a daily, weekly, or monthly cycle. The problem is I have no idea how to set up the randomization, or how to get an array of members for each membergroup selected (basically an array of membergroups where each array item has an array of all the members within it)
Here's my code so far (I have this one planned out a lot better with comments than my previous plugin) Most of it's pretty empty, but I can't really do anything until I can get the randomization set up.
//Set the rates of different rotations var rotateTime = pb.plugin.get('member_spotlight').settings.rotation;
if(rotateTime == "rotateDaily") { }
if(rotateTime == "rotateWeekly") { }
if(rotateTime == "rotateMonthly") { }
//Set an array of membergroups var memGroups = pb.plugin.get('member_spotlight').settings.memberGroups; var searchGroups = {}; for(a=0;a<memGroups.length;a++) { searchGroups = { }; }
//Randomly choose member $(document).ready(function() { //Retrieve the information of the randomly selected member //Set the information into usable variables //Display the results in a div tag with ID of memberSpotlight var div = $(this).find("#memberSpotlight") $(div).prepend('doot'); });
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Apr 6, 2015 0:40:36 GMT -8
you wont be able to extract from the server a list of members under a member group in a plugin. you also wont be able to extract user information from a member based on username or id from the server. you would need to add all that into the plugin settings itself.
|
|
Aeon
New Member
Posts: 46
inherit
aeonofeternity@gmail.com
196622
0
Mar 26, 2023 22:20:33 GMT -8
Aeon
46
July 2013
eon
|
Post by Aeon on Apr 6, 2015 16:48:18 GMT -8
you wont be able to extract from the server a list of members under a member group in a plugin. you also wont be able to extract user information from a member based on username or id from the server. you would need to add all that into the plugin settings itself. All I'm pulling for information are username and avatar, both possible with javascript as I have javascript in a sidebar on the site that pulls it for the current user. Pulling it by ID should be no harder than pulling things like birthdays or post counts. As for the array, rather than just saying "you can't", it would have been more helpful and prudent to suggest making the settings of the plugin select individual users rather than membergroups. Or another option that could have been suggested would have been making if statements that check for membergroup number after randomizing, then redoing the randomization if the selected member was not in an approved membergroup. (I had quite a bit of time to do brainstorming while being stuck at the grocery store with my grandparents today) Basically, try to be a bit actually helpful rather than just posting discouraging messages when someone's looking for help with this stuff.
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Apr 6, 2015 17:16:34 GMT -8
CURRENT user sure. but you arent going to be able to get any information from the server that isnt already on the page. You can get mad at me all you want for not adding fluffy clouds to what Im saying, but Im handing you straight facts. It isnt possible, dont tear out your hair trying to make it work.
I said you would need to put all your user information into the plugin settings. that is what you would need in order to get a random user info from an array. again Im not going to put fluffy clouds on the advice. Im giving you exactly your best option.
All these other "other suggestions" you wanted me to provide, did not follow the scope of the project you were advertising.
But if you dont want to hear what I have to say, I cant argue with that. I will just step back.
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Apr 6, 2015 17:33:13 GMT -8
I'm working on a plugin that will allow staff to select certain membergroups in the plugin settings, then have the plugin show a random member from those groups on a daily, weekly, or monthly cycle. The problem is I have no idea how to set up the randomization, or how to get an array of members for each membergroup selected (basically an array of membergroups where each array item has an array of all the members within it) Here's my code so far (I have this one planned out a lot better with comments than my previous plugin) Most of it's pretty empty, but I can't really do anything until I can get the randomization set up. //Set the rates of different rotations var rotateTime = pb.plugin.get('member_spotlight').settings.rotation;
if(rotateTime == "rotateDaily") { }
if(rotateTime == "rotateWeekly") { }
if(rotateTime == "rotateMonthly") { }
//Set an array of membergroups var memGroups = pb.plugin.get('member_spotlight').settings.memberGroups; var searchGroups = {}; for(a=0;a<memGroups.length;a++) { searchGroups = { }; }
//Randomly choose member $(document).ready(function() { //Retrieve the information of the randomly selected member //Set the information into usable variables //Display the results in a div tag with ID of memberSpotlight var div = $(this).find("#memberSpotlight") $(div).prepend('doot'); }); Wormo is being polite. If the user isn't on the page, you can't pull from the database. So all of the users and groups needs to be added in the plugin settings manually. Pb.member.select() will load a user's data, however such calls must be made with the current user's interaction. This is searched by user name/display name. Long story short, you will have to set it up manually every week etc or have a local user save it to a key. Otherwise the user's would never see the same user chosen in the first place. This goes back to the age old problem, not having every members data loaded in one place. Now you can view users in a group and have their information on the groups page. But only for small group sizes. Otherwise it's split into multiple pages. example: site/members?group=1&view=group You have all the users in that group and their info available. (up to a certain amount of users) This would be a place where you could go to randomly pick a user and save their information in a forum key. (which would mean you are changing it week by week. Albeit, with only a few clicks of a button) I'm assuming this is the information you were looking for. So you have some choosing to do. But you might be like what the heck did I just read. So in summary: Can't be automated. Can be done if using small groups. Can be done with large groups if you put in the information in a large table under plugin settings as wormo suggested. Group information for users can be used, if you use your plugin on the groups page. And the group doesn't have so many members that it's split into two or more pages. You would have to manually save the new data to a key or to your plugin settings daily/weekly/monthly But you would only have to click one button to generate the information you need to copy.(or auto save to forum key) Otherwise, you can do everything you want in the plugin, if you put in all the users names and groups in an autoform or codebox. Before you generate your data. (but you're still going to have to copy who the lucky randomly generated user is) Technically you could force the user to navigate to the member page and update the data by clicking the button however this is unwise. The reason being that if multiple users were forced to update that data before being able to continue navigating the site, they would be confused, and they may actually generate a random selection each, and one of the user's data would overwrite the others. There are more complicated ways to make sure they don't overwrite each other though.
|
|