Modify Usergroup

Started by MrLeN, April 28, 2011, 12:35:22 PM

Previous topic - Next topic

MrLeN

I want to create some PHP which will modify a users membergoup, depending on the contents of an associated text file.

Something along the lines of:


*get users username from the database here and create a variable called $username*
include_once $username .  '.txt';
if ($vip= "1") {
  *php code to modify the users membergroup in the database here*
}


note: I will already have created a file called:

username.txt which will contain:


$vip = "1";


I don't know how to connect to the database, or get the current username out.

Can anyone fill in the blanks?

I am using smf 1.1.13

Suki

well, I wouldn't use a text file to get info from, its slower and will potentially have thousands of files ;)

how about add an extra column to the members table named "vip"  and fill it with an integer  either 0 or 1?  and then you can just query members table to get the username of those users who have 1 in the vip column:



$request = db_query("
SELECT ID_MEMBER, realName, posts
FROM {$db_prefix}members
WHERE vip = 1
", __FILE__, __LINE__);
$return = array();
while ($row = mysql_fetch_assoc($request))
$return[] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realName'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>',
'posts' => $row['posts']
);
mysql_free_result($request);




Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

MrLeN

Because what I want to do is accept a $5.00 AlertPay payment, so that I can give people VIP status.

However, they must already have referred 2 people.

So, what I am doing is making a flatfile system where if anyone joins from a particular username, I will have php create a text file called username.txt and put number 1 in there.

Then when that user invites a second person, it will change to number 2, and then activate the code I am asking about, and delete the text file, because it will no longer be necessary.

I am not very good with databases, and I kinda didn't want to manipulate the SMF  database just to keep track of a count which will be deleted after it hits 2.

Plus, if I DID fiddle with the database, I would most assuredly break it O_o

If I can just figure out the code I need (as above), I'm right to go.

Suki

That could be done with tables with out any worry of breaking it :) , key of coding is made things as simple and as effective as possible ;)
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Matthew K.

Miss All Sunday is right, in addition to that, have you considered using the SMF 2.0 branch? There is a built-in subscriptions system which would work in this scenario perfectly for you.

MrLeN

If I don't even know how to extract a username and connect to the database, what makes you think I am going to be adding tables and using 2.0 branches? O_o

ie: I don't know how.

Matthew K.

Using the 2.0 branch would not require you to modify the db.

MrLeN

If anyone can show me how to do what I asked, I would appreciate it.

Matthew K.

There's a built in subscriptions system to SMF 2.0 RCx. So you'd need to upgrade (Upgrading SMF) and then setup a subscription that once purchased, would add the members to your VIP membergroup.

MrLeN

Look, I don't want to sound unthankful or arrogant, and I realise I am the one asking for help here, so I should be nice, but all you're doing is p'ing me off.

I came here and asked a specific question, because I've already thought about what I need.

I don't want to upgrade SMF. That will cause so many more problems on my highly customized board, that I'd have to spend a week to deal with it, and there are many problems that most likely couldn't be fixed. So that option is out. I don't "upgrade" highly modified boards. In my experience, that's just the best way to totally destroy the board so thoroughly, that it is not repairable and you have to start all over again.

Secondly, I don't want people to set up a subscription. All I want is to change their membergroup.

Thirdly, I have 2 other scripts (a chat script and a video chat script) that will be reading the same text file that I am referring to. I don't want to change their databases too.

I don't want to stuff around all day, upgrading software, hacking up databases and everything else, when all I need to do is create 1 text file that will be deleted once it is no longer necessary. And that text file has NOTHONG to do with a "subscription". It is a referral count which several softwares are supposed to use to know whether the user has referred 2 people "besides" also paying money.

Lastly, I've already spent weeks building a flat file members area that counts referrals, so that I can read the text files from other domains and know whether a username is a VIP member or not.

The thing I can't stand about many people is if you try to get them to help you, they don't help you, but sit there trying to tell you what you "really" need.

Then you look at them with a blank face for about 10 seconds, considering everything they've said to you 3 times over, and then say: "Um, no, actually, I am petty sure I'd like you to help me what I asked for".

Then, if they try to tell you what you "really" need again, it becomes the opposite of help. It becomes very unhelpful and annoying.

Please, if someone can just show me how to do what I originally asked, I'll send you flowers and give you hugs.

If you don't want to, because you are absolutely convinced hat you know what I "really" need, please don't reply.

I am sorry if I sound rude, but this is one of my pet peeves in life.

Suki

OK...

* Miss All Sunday is going to leave this topic in silence now...
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

MrLeN

I'll figure it out myself..

Sheesh!

live627

Labradoodle-360, don't go pushing SMF 2 at people. They will upgrade on their own when they feel ready.

Arantor

To update the user group (which is a database change no matter how you slice it), make sure SSI.php is included which will give you database access, then include Sources/Subs-Members.php and call addMembersToGroup.

Baby Daisy

Quote from: Arantor on April 29, 2011, 09:48:22 AM
To update the user group (which is a database change no matter how you slice it), make sure SSI.php is included which will give you database access, then include Sources/Subs-Members.php and call addMembersToGroup.

If you're going to go about this route, note that it requires the manage_membergroups permission.
あなたは私のお尻にキスするとき、私はそれを愛する

Arantor

Why do you think I linked the page on the function DB about it?

Baby Daisy

Oh, didn't realize the notes at the bottom. :P
あなたは私のお尻にキスするとき、私はそれを愛する

MrLeN

I have created a new usergroup called VIP Member

How can I display text on a  page only for that group?

ie:

if (user is VIP member) {
  echo "You can see the VIP stuff!";
}
else {
  //user gets to see nothing
}

P.S. I have decided to add members to the group, manually, by hand -- because no one will show me how to do it with PHP. So now, when someone finishes paying $5.00, I will get an email saying "username has paid $5.00". Then I have to go and add them to the membergroup. It will get old, but I don't know how to add a user to a membergroup with php, and if I ask here, all I get is everything and anything BUT what I asked (which is not helpful).

ascaland

Quote from: MrLeN on April 30, 2011, 07:30:12 PM
P.S. I have decided to add members to the group, manually, by hand -- because no one will show me how to do it with PHP. So now, when someone finishes paying $5.00, I will get an email saying "username has paid $5.00". Then I have to go and add them to the membergroup. It will get old, but I don't know how to add a user to a membergroup with php, and if I ask here, all I get is everything and anything BUT what I asked (which is not helpful).

Uhhh...?

Quote from: Once Upon A Star on April 29, 2011, 09:48:22 AM
To update the user group (which is a database change no matter how you slice it), make sure SSI.php is included which will give you database access, then include Sources/Subs-Members.php and call addMembersToGroup.

MrLeN

#19
I just got a PM from someone who thinks I can't be bothered learning, and why should people help me?

http://support.simplemachines.org/function_db/index.php?action=view_function;id=593

Ok, let me start there!


bool addMembersToGroup (mixed $members, int $group[, string $type])


What does that even mean?

mixed, int, string:

I don't know if these are a part of PHP, or whether they're to signify that I need to put something there.

I have no idea what BOOL is.

Where do the values for $member, $group or $type come from?

Just because some people are very familiar with all this code, and know what it all means, it doesn't mean you should expect someone else to understand, and then make out like they're stupid if they don't understand!

There's a reason I came and asked for help, because I don't know how to do what I want to do.

My original question is REALLY FRICKING SIMPLY laid out!

I went to the trouble of explaining exactly what I am doing, and exactly how., I showed the code that I am able to do myself, and asked for help for the rest (which I quite FRICKIN' obviously don't know how to do)..

..and look at the bloomin' responses!?

HAVE A LOOK AT THEM!

One guy incessantly trying to get me to upgrade to a totally different FRICKIN' forum!

Other person showing me a page of SOMETHING tat looks like ancient frickin' Hebrew to me!

Someone else just saying HUUUUH? At perfect English.

PM saying no one should help me and I don't want to learn.

Someone telling me to start adding tables in the database.

I have ASKED TWO FRICKIN' QUESTIONS (AND THEY'RE PRETTY SIMPLE ONES)...

..and i know for a FACT, that what I have asked is NOT hard for someone who know's what they're doing.

There are heaps of people on this forum, that could fill in the gaps for me right off the top of their head.

But NOOOOO, we can't do that can we? We've got to make the guy who doesn't know what he's doing squirm, and beg, and plead, and lets make some fun of him and make him out to be STUPID.

Ok, YOU  might know what you're doing. YOU are the smartest guys on earth. You've demonstrated how bloody fantastic you are and how beneath you I am..

..but for crying out loud, can SOMEONE please answer the questions I FRICKIN' asked, instead of giving me everything and anything you can think of that doesn't actually fricking help!


*%#*^%@#*^%#@

AAAARGHH*^%#&$@^@^

_)*$(&o#&i%#@

Advertisement: