Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 01 Mar 2011, 22:34
kvnband kvnband is offline
 
Join Date: Feb 2004
Real name: Kevin
New to VB programming, but not PHP. Simple plugin question

OK - I am new to the world of programming products and plugins for VB, but not to PHP development in general. For my first project, I have created 5 custom profile fields in the admincp. We have a large, established user-base, and I need to make sure that these 5 fields are filled out, for tax purposes (We are a non-profit org).

So, how do I proceed? I basically just need to know how I check the logged-in user's custom profile fields at the start of each page load. I assume writing a small plugin is the way forward here, but aside from that, I'm completely clueless.

Any help?

Thanks!
Reply With Quote
  #2  
Old 01 Mar 2011, 23:08
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
When you create (or edit) the profile field, there is the option to make the Field Required. If you have it set to show on the Edit Profile page, then the user will get told they need to edit their profile before continuing to do anything on the site. (Admins are exempt from this, I believe.)
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #3  
Old 01 Mar 2011, 23:26
kvnband kvnband is offline
 
Join Date: Feb 2004
Real name: Kevin
That's what I thought, Lynne. But since implementing the fields, we have had about 10 users sign on and post in the forum. None of them have updated those fields. The fields are set to be required at registration and profile editing, and are set to be editable by the user.

Since nobody updated their information, I assumed it wasn't a built-in feature and that I would need to write a little plugin to force them to.

--------------- Added 01 Mar 2011 at 23:42 ---------------

So I'm just an idiot. I didn't notice that one of the options for "required" was "Yes, Always". Set that, and it appears to be working.

Now - Where can I go to learn about VB programming in general? I need to come up with an election voting module here in the next 3 months. I could do it in a few hours in pure PHP but I'm clueless where to even start with making a VB product....

Last edited by kvnband; 01 Mar 2011 at 23:42. Reason: Auto-Merged DoublePost
Reply With Quote
  #4  
Old 01 Mar 2011, 23:47
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Do not set it to Field Required "Yes, at registration and profile updating", set it to "Yes, always". And, what did you set for Which page display this option?
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #5  
Old 02 Mar 2011, 00:24
kvnband kvnband is offline
 
Join Date: Feb 2004
Real name: Kevin
Lynne - I edited my post right before you replied...Your solution was spot on though.

Now - Where can I go to learn about VB programming in general? I need to come up with an election voting module here in the next 3 months. I could do it in a few hours in pure PHP but I'm clueless where to even start with making a VB product....
Reply With Quote
  #6  
Old 02 Mar 2011, 05:27
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Glad you got that working.

The way I learned how to code vb was by first downloading simply mods and seeing how they were done. Then I started wanting to do things my self and so I would download mods that kinda did what I wanted and then I would modify them to do what I wanted. So, I kinda learned how things worked by doing it that way.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #7  
Old 02 Mar 2011, 13:43
kvnband kvnband is offline
 
Join Date: Feb 2004
Real name: Kevin
I think I'm going to do just that, but keep it basic at first. Create my new bitfield permissions (Who can create elections, who can vote in elections, who can see election results) and then just use the forum front-end for the administration of things at first. That way I can just have plain PHP files out there that only tie in to VB when checking for permissions. Seems like a decent way to get started....

And yes - I will definitely need to check out other products for inspiration. I think I can figure things out.

Thanks for your help.

--------------- Added 02 Mar 2011 at 20:25 ---------------

Soooo I need help again. I created my product, set up my bitfields, and set up my permissions. But I absolutely cannot figure out how to check those permissions in my script. I see that I'm obviously not accessing the correct values, but I don't know where else to check. I am trying to see if the currently logged in user has permission to vote or not. This is just real basic while I'm trying to acclimate myself to the system. Can you help me / point me in the right direction?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by kvnband; 02 Mar 2011 at 20:25. Reason: Auto-Merged DoublePost
Reply With Quote
  #8  
Old 02 Mar 2011, 22:02
wpeloquin wpeloquin is offline
 
Join Date: May 2006
If you set up a Setting Group for the plugin in the AdminCP > Options, you would use something like

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

customplugin_enable would be a yesno field (turn on/off the plugin) and the customplugin_votegroups would be a comma separated list

i'd recommend putting the typical 5, 6, 7 as default for the _votegroups, blank Option Code, and add something like (comma separated ID list) in the description
Reply With Quote
  #9  
Old 02 Mar 2011, 22:17
kvnband kvnband is offline
 
Join Date: Feb 2004
Real name: Kevin
Thanks for your response. I actually came with that method on my own on another product I was tinkering with, but I don't want to go that route with this product. With this product, I want to control the usergroup permissions in the usergroup editor. So I've successfully set up the /admincp stuff, but I just can't figure out how to check if one of the current member's usergroups 'canvote'.

I do appreciate your help. Hopefully you have an idea on how to accomplish it this alternative way...
Reply With Quote
  #10  
Old 02 Mar 2011, 22:53
wpeloquin wpeloquin is offline
 
Join Date: May 2006
I assume you mean add a custom section in the AdminCP > Usergroups > Usergroup Manager > Edit Usergroup, something like how it has Forum Viewing Permissions, Forum Searching Permissions, etc?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

if so, i am sure there is a way to do it, as i've seen other plugins do it. However, i cannot help with that . Hopefully this helps some though, if anyone else does know!
Reply With Quote
  #11  
Old 02 Mar 2011, 23:08
kvnband kvnband is offline
 
Join Date: Feb 2004
Real name: Kevin
Yes, that is exactly what I'm talking about. I have already implemented the bitfields (That part is incredibly easy, actually) but I don't know how to check them on the front-end. Hopefully someone can chime in.
Reply With Quote
  #12  
Old 04 Mar 2011, 02:18
kvnband kvnband is offline
 
Join Date: Feb 2004
Real name: Kevin
So, I've made some progress. I thought I was doing good, until I went to create an update form. Does vBulletin have some sort of special trickery regarding $_POST? I have a basic update form that posts back to itself. But no matter what I do, I cannot get the dang thing to do anything. When I hit submit, I just get a blank page. Getting frustrated here...

Here is my PHP:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Here is my form template:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The form loads up and looks fine, and is prefilled with the user's data, if it is available (I realize that this code is not exactly right, but it's working for now). But when I hit submit, I get a blank page, even though I have coded for it in the PHP file.

Obviously I'm missing something important here.

Any advice is appreciated.

--------------- Added 04 Mar 2011 at 02:20 ---------------

Edit - Wow. I looked at this code for 20 minutes and couldn't figure out my problem. Posted here and almost instantly realized that I wrote $_SREVER instead of $_SERVER......

I'm leaving it here as a learning experience for others.

Last edited by kvnband; 04 Mar 2011 at 02:20. Reason: Auto-Merged DoublePost
Reply With Quote
  #13  
Old 04 Mar 2011, 02:43
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Spell check is your friend.
Reply With Quote
  #14  
Old 04 Mar 2011, 02:51
kvnband kvnband is offline
 
Join Date: Feb 2004
Real name: Kevin
I normally would catch an issue like that. But since this is all going on inside of VB, I'm quick to think I've messed something up inside there.

This really isn't all that hard so far. Just have to remember what variables I can access and it's pretty breezy.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 13:42.

Layout Options | Width: Wide Color: