edit user functions

Discussion forum for MOD Writers regarding MOD Development.
Locked
TwoThirdsWater
Registered User
Posts: 5
Joined: Tue Sep 07, 2010 9:31 am

edit user functions

Post by TwoThirdsWater »

Hullo board

I am writing a set of functions to interact with phpBB to allow a me to create, delete and edit phpBB users by code.

I've managed to get the add_user and delete_user functions to work, but cannot make either user_ban() or user_update_name() work. Its quite possible that I am missunderstanding the purpose or desired effect of these methods, but i'd appreciate anyones advise as to what I am doing wrong please.

1) I want to be able to deactivate a users account (stop them from logging in). I figure banning them is the best option from the methods available to me. When using the following code:

Code: Select all

user_ban  ("user", $_GET["user_name"], 2629743, "2050-12-31", true, "User has been set to inactive on by the main admin");
i get a general SQL error:

Code: Select all

General Error
SQL ERROR [ mysql4 ]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 [1064]
An sql error occurred while fetching this page. Please contact an administrator if this problem persists.
I am trying to ban them for 5 years (using the minutes) and have just added in the ban date too as i wasn't sure if the empty string I was using there was responsible for the SQL errors.

2) I want to be able to change a users username. It would appear from the documentation that user_update_name() should do it. However when running the following code:

Code: Select all

user_update_name  ( $_GET["old_user_name"], $_GET["new_user_name"]);
I don't get any errors, and yet the phpBB username table doesn't show any changes.

Thanks in advance for your help!

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5449
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: edit user functions

Post by Marc »

Could you maybe post those 2 functions? Without those functions, it will be pretty hard to help you.

Drummer
Registered User
Posts: 199
Joined: Wed Jul 21, 2010 11:49 am

Re: edit user functions

Post by Drummer »

user_update_name() does not change the user's name, it updates the fields that uses usernames in certain tables (like forum_last_poster_name in the table forums). To change an user's username just update the username and username_clean fields in the users table and then call user_update_name() to make sure that there won't be a non-existing author (or moderator).

For the first problem i think you need to post more debugging info like the sql query and the first lines of the X file. What file is this btw?
Just two notes:
  • the 5th argument ($ban_exclude) must be false if you're banning, true if excluding.
  • to use the 4th arg ($ban_len_other) the 3rd ($ban_len) has to be -1.

TwoThirdsWater
Registered User
Posts: 5
Joined: Tue Sep 07, 2010 9:31 am

Re: edit user functions

Post by TwoThirdsWater »

Thanks Drummer...

I have now sorted the username issue out, but am still struggling with the ban code.

I'm not even sure whether I would be better banning or excluding... essentially I just want to stop people accessing the forum, but not to delete all their posts and so.

I've moved on from the SQL error I was getting (thanks for the -1 advise), but I am now being returned an whole bunch of HTML that reads:

Code: Select all

yourdomain.com
A short text to describe your forum

Skip to content
Advanced search

    * Board index
    * Change font size
    * FAQ
    * Register
    * Login

Information
[b]The requested users do not exist.[/b]

    * Board index
    * The team • Delete all board cookies • All times are UTC

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
However I am sure the username being passed is a valid forum users, I have even tried using the clean name to see if that helps, but to no avail.

This is the code I am using...

Code: Select all

user_ban  ("user", $_GET["user_name"], 2629743, null, false, "User has been set to inactive");
$_GET["user_name"] holds a valid username.

I apologize for this generic question... I am finding if very hard to debug my own phpBB as I can't find any detailed documentation... the best I have found so far is: http://area51.phpbb.com/docs/code/ which is pretty top level.

Again... anything you or anyone can do to help much appreciated. Thanks in advance.

TwoThirdsWater
Registered User
Posts: 5
Joined: Tue Sep 07, 2010 9:31 am

Re: edit user functions

Post by TwoThirdsWater »

Ah HAAAAA (to quote Alan Partridge).

The issue I was getting was because $user isn't defined in the function (as I am calling the function from outside phpBB). Had to do a hack to the functions_user.php file which isn't ideal.

Locked

Return to “[3.0.x] MOD Writers Discussion”