![]() |
vB_DataManager_Thread, How do I do?
Hey!
I am trying to generate threads with the class: vB_DataManager_Thread. I tried searching Google and the forums. I couldn't really find what I need. I need a simple piece of code on how to make a thread in forum, by userid, with contents and dateline. I have seached a lot, Thanks in advance, Ralle |
hi,
You must create a datamanager instance set the things you want to set check for errors and finally when things are ok save them PHP Code:
|
Never mind, I fixed it.
I replaced all setr with set Once again, thank you! Quote:
|
In setr the value is passed as a reference. (So it must be a variable I assume.)
PHP Code:
|
Correct - setr() means set by reference, so cannot be a constant.
|
I am getting the following error:
That username is already in use or does not meet the administrator's standards. any ideas? |
Didn't you read the error?
Quote:
You probably need to add something like: PHP Code:
|
Quote:
It just doesn't make sense to me. I already have: PHP Code:
|
What is the value of $uname? Also make sure it is set to the username of the member with the same userid which is defined earlier.
|
Here is my entire script - the variables in $_GET are all form variables being sent via AJAX to a page processing the form and creating a new thread:
PHP Code:
|
You don't need to escape anything going into datamanagers as they do the escaping for you.
|
OK removing the escaping does not fix the error though:
Quote:
|
What are the values of $uname and $userid just before you set them for the thread datamanager?
(I know you set them as $_GET bla bla but post an example you get when you run the script, it may be that it is not being assigned correctly somewhere else) |
$uid = 1
$uname = 'admintw42' Both of these values are correct for my user account. If I set this to another user id & name it still fails with the same error. If I set this to a username and id that does not exist I get a different error (no users match query) which is just what I would expect. Quote:
Is that call being handled directly within the line: PHP Code:
PHP Code:
Sorry for all the questions - vBulletin is complex! |
Hmm I don't know exactly what the problem is. How about hard coding the username and userid in the script and seeing if it works that way. I don't see why the vB code isn't working so its best to start from the beginning and work through to identify the problem.
Also try running this on your script and checking if the username returned matches $uname. PHP Code:
|
Using that piece of code I get:
string(9) "admintw42" I don't have access to $user_userid or $user_username .... The values are being passed from the page before in an AJAX call. Does vB somehow not recognize the script as having permissions to create a thread? Is there something I could do to make vB recognize that I am the logged in user on the page that is running this code? Actually a closer look at the remainder of the error says: Quote:
|
Quote:
Place PHP Code:
PHP Code:
I'm sure there is something easy were missing lol :erm: |
Quote:
PHP Code:
Adding : PHP Code:
string(9) "admintw42" [QUOTEI'm sure there is something easy were missing lol :erm:[/QUOTE] I hope so - this is one of those 2% tasks taking 98% of the time. Is there an equivalent line of code needed before: PHP Code:
bump. anyone? this error is dogging me. I think it has something to do with the server script somehow not being "allowed" to post. |
Hmm I'm not to sure, I'll run some test of my own see if I can make it work. I'll let you know of the results, won't be soon though so keep trying to figure it out.
|
I am trying to use the vb_DataManager_Thread_FirstPost to insert a new thread on behalf of a user who has filled out a form on a page which calls this script vis AJAX.
The script SHOULD create a new thread in a specified forum and attribute the thread/post to the user who filled in the form. Unfortunately what I am getting in return is the following error: Quote:
Does anyone know what needs to be done to enable the script permissions as the user to create a new thread? Source below - one thing I am not sure of is the line: Quote:
PHP Code:
|
PHP Code:
|
Interestingly I am back at the error:
Quote:
the two lines of code: PHP Code:
Quote:
Quote:
--------------- Added at 13:07 --------------- ok here is my script currently and still facing the error: Quote:
PHP Code:
|
This is how you should do it; of course, leaving this as it is means inviting malicious users to abuse it, but I think you mentioned this was part of a bigger AJAX script. Another suggestion, which I have not implemented here because I do not know exactly what each variable will contain, is to always use vBulletin GPC variable instead than accessing $_GET directly. In fact, while it's true that DataManagers do data validation for you, you may never know when you are going to use the data in some other bits of the code; better safe than sorry, always.
PHP Code:
|
Hello again guys.
I am sorry to revive this thread but I now also learned how to delete a thread. So now the big question is. How do I undelete it? PS. I delete threads softly. |
PHP Code:
|
All times are GMT. The time now is 07:46 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|