Hi..
Wonder if any of you smart coders could help me with a feature I really want...
I got Ultimate Profiles set up, and want to make more use of the great buddy and profile page system that mod provides.
So, for new registered members, my dream is to have a welcome post and auto request "add buddy" to this new user from the Admin.
New registered user feature
- Auto post a welcome message from Admin at the users profile page
- Auto request "add to buddy" to this new user from Admin
Hope anyone can help!:)
Much apreciated
For the first:
http://custom.simplemachines.org/mods/index.php?mod=387
For the second, I couldn't get what you meant. Do you want to automatically add the user registered as the admins buddy?
Quote from: [SiNaN] on August 05, 2008, 02:20:54 PM
For the first:
http://custom.simplemachines.org/mods/index.php?mod=387
For the second, I couldn't get what you meant. Do you want to automatically add the user registered as the admins buddy?
Hey thanx for the link ;) Almost what I wanted, but can do..
What I really wanted was this :
- Admin auto request buddy for new registered members
- Admin auto post a welcome message at their profile page (not PM)
If anyone have any tips or code for that, I'd love to see :)
Are you using a kind of a Ultimate Profile?
yes, exactly ;) Thats why I want to direct people to that page when they register...
To get them all to see the Ultimate Profile page, and to start using it...
Want to see if we can get this nice mod more active..
For the 1st one, Welcome Message on registration:- http://custom.simplemachines.org/mods/index.php?mod=789
I dont know about the second one, hope that info helps.
Thanx flamer...
Both mods are pretty close... Both the auto welcome PM above , and yours that create auto TOPIC...
What I would love, is not PM/Topic, but a auto welcome message at their PROFILE page ;)
But I'll look into the code of both links posted in this thread, maybe I can figure out a way to change it to auto PROFILE post ;)
O:)
That would be like settings up a default text that is to be shown to all the registered users in their profile.
Admin --> Features and Options --> Default personal text Text
That will be shown just under the avatar of the newly registered user. Thats how far i can think of.
You are asking for a message that would appear up when they would visit their profile 1st time, and next time they go to their profile the message is disappeared. Maybe that is what you are trying to explain. Is it ?
Hope my info helps you out.
Quote from: F.L.A.M.E.R on August 06, 2008, 07:59:53 PM
You are asking for a message that would appear up when they would visit their profile 1st time, and next time they go to their profile the message is disappeared. Maybe that is what you are trying to explain. Is it ?
Hope my info helps you out.
Yes, almost :) It doest have to disapear, or show first time they visit. Doesnt have to be that advanced. Rather just a simple auto welcome post at their profile page, when they register a new account. This post would show as posted from Admin, and function as a welcome message at their (ultimate) profile page....
"Welcome to the community, hope you enjoy the say. Please take time to fill out your profile into....etc"
That kinda welcome message.
Almost identical to the Auto PM welcome mod, but for profile page, instead of PM
I got Ultimate Profile running (Awesome mod), where people can post comments, add buddies, etc etc. In ways, a bit "my space" ish...
And the idea with the auto welcome post at profile, is to direct new users to see this system (ultimate profile), and hopefully take it into use :)
hope that made sense :)
Trying asking this features in the Ultimate Profile mod support topic. May be I can have a look when I have some time.
Thanx, but I know you have great mods that you're working on, so I wouldnt want to take your time ;)
I'll try a bit myself, might figure it out. :)
Okay, anyway I did it for you;
../Sources/Register.php
Find:
$memberID = registerMember($regOptions);
Replace:
$memberID = registerMember($regOptions);
loadLanguage('UltimateProfile');
db_query("
INSERT INTO {$db_prefix}profile_comments
(ID_MEMBER, comment, time, COMMENT_MEMBER_ID)
VALUES (1453, 'Welcome to our forum!', '" . time() . "', $memberID)", __FILE__, __LINE__);
db_query("
INSERT INTO {$db_prefix}buddies
(ID_MEMBER, BUDDY_ID, approved, position, time_updated, requested)
VALUES (1453, $memberID, 0, 1, '" . time() . "', 1453)", __FILE__, __LINE__);
require_once $sourcedir . '/Subs-Post.php';
sendpm (array('to' => array($memberID), 'bcc' => array()), sprintf ($txt['buddy_notif_new_subject'], $_POST['user']), sprintf ($txt['buddy_notif_new_body'], $_POST['user'], $scripturl . '?action=buddies'), false, array ('id' => 0, 'name' => $txt['profile_notif_com_user'], 'username' => $txt['profile_notif_com_user']));
Chanage 1453 as the ID of the admin.
Note that only works with Ultimate Profile mod. For further requests ask in the mod's support topic.
Wow, thanks a bunch, you're an angel! :D
Worked like a charm, except that the PM to the new users (about Admin wanting to be buddy),
The request is sent from Admin (as should), but the request to the new user is about adding himself to his own buddy list, and not the Admin. In other words, the new user is requested to add himself to be his own buddy, by Forum Admin;)
But I'll try figure out why, in last part of the code...
The auto welcome post on the profile page worked fantastic though! Thanx a million :D :D
Let's solve the problem and then I'll accept the "thanks". :P
I never used this mod, so I'm not too familiar with codes but let's try this:
In codes,
Find:
VALUES (1453, $memberID, 0, 1, '" . time() . "', 1453)", __FILE__, __LINE__);
Replace:
VALUES ($memberID, 1453, 0, 1, '" . time() . "', 1453)", __FILE__, __LINE__);
If doesn't work, try replacing with this:
VALUES ($memberID, $memberID, 0, 1, '" . time() . "', 1453)", __FILE__, __LINE__);
Quote from: [SiNaN] on August 10, 2008, 11:07:22 PM
Find:
VALUES (1453, $memberID, 0, 1, '" . time() . "', 1453)", __FILE__, __LINE__);
Replace:
VALUES ($memberID, 1453, 0, 1, '" . time() . "', 1453)", __FILE__, __LINE__);
That worked :D :D
Fantastic! Thanx a bunch.. :)
Really apreciated, awesome help
Which worked for you?
Cause neither had any result for me ????
Could you quickly look at my template please [SiNaN]??
I tried both probably 3 times each to no success.
Thank You
EDIT: The member number is 1
What's the error you get?
It still displays the user wanting to add himself as a buddy.
Say I reg as Test 1, it will state that Test 1 wants to be my buddy, instead of the prescribed user.
I had to set up a local, install the mod, change the original Register.php with the one you attached.
Result: It works perfect.
Sorry, you mean the name is wrong. Just replace the $_POST['user'] with 'YOUR_NAME'.
'YOUR_NAME' is the username of the admin account.
Note: If you want we can code a new query and get the username of the admin automatically but I don't think we really need that.
yes, I changed that part..... I forgot to mention. The actual PM text was wrong too :) Here is the complete code that I use that works fantastic, with fixed PM text
Thanx a lot to [SiNaN].... :)
// Auto Post at profile mod
loadLanguage('UltimateProfile');
db_query("
INSERT INTO {$db_prefix}profile_comments
(ID_MEMBER, comment, time, COMMENT_MEMBER_ID)
VALUES (2, 'Hi there<br>Welcome to our forum!<br>Hope you enjoy the stay, and come back often :)', '" . time() . "', $memberID)", __FILE__, __LINE__);
db_query("
INSERT INTO {$db_prefix}buddies
(ID_MEMBER, BUDDY_ID, approved, position, time_updated, requested)
VALUES ($memberID, 2, 0, 1, '" . time() . "', 2)", __FILE__, __LINE__);
// Post a PM about the Buddy request too
require_once $sourcedir . '/Subs-Post.php';
// Set up the PM message array
$pmfrom = array(
'id' => 2, // change to correct ID for PM to be sent FROM
'name' => 'Forum Admin name', // change to the NAME for PM to be sent from
);
// send the PM :)
sendpm (array('to' => array($memberID), 'bcc' => array()), sprintf ($txt['buddy_notif_new_subject'], $pmfrom['name']), sprintf ($txt['buddy_notif_new_body'], $pmfrom['name'], $scripturl . '?action=buddies'), false, array ('id' => 2, 'name' => $txt['profile_notif_com_user'], 'username' => $txt['profile_notif_com_user']));
// end of auto post on profile
NOTE : The ID on MY forum for Admin, is 2. Change to your correct ID for your Admin (or user you want to be doing the auto message & PM)
:)
Mod originally sends pm as a guest called "Notifier".
Quote from: [SiNaN] on August 11, 2008, 06:02:51 AM
Mod originally sends pm as a guest called "Notifier".
That would be even better... But it didnt do that :)
It shows sent from Admin, but with wrong text for subject and body.... (asking user to add himself to buddy).
So even after your first fix (making the actual buddy request correct), the PM text was still wrong...
I fixed that by the code I put..
But it might somewhat be better if it came from the notifier. (as other buddy requests do). But not a big deal ;)
The code I put, will send a PM from Admin, with correct text , saying "Admin wants to be your buddy etc"
So that works fine too :)
Quote from: [SiNaN] on August 11, 2008, 05:50:56 AM
Sorry, you mean the name is wrong. Just replace the $_POST['user'] with 'YOUR_NAME'.
'YOUR_NAME' is the username of the admin account.
Note: If you want we can code a new query and get the username of the admin automatically but I don't think we really need that.
Just this would fix the subject and body of the pm. The rest works perfect, it sends pm as "Notifier".
Brilliant guys, thanks for that :)
I have my "Community Member" (Profile all staff use for announcements/greetings etc) asking to be a buddy, and Myself leaving the profile message :)
Makes me look really involved with everyone! lol
Cheers :)
ah, sorry, you are correct :D:D
I changed a part in my code by mistake...
array ('id' => 2
ID 2 is my admin.
This should be ZERO as you set it, for the PM to be sent from NOTIFIER
So here is the complete code I now use, that does everything correct, including the PM from notifier, with correct text
// Auto Post at profile mod
loadLanguage('UltimateProfile');
db_query("
INSERT INTO {$db_prefix}profile_comments
(ID_MEMBER, comment, time, COMMENT_MEMBER_ID)
VALUES (2, 'Hi there<br>Welcome to our forum!<br>Hope you enjoy the stay, and come back often :)', '" . time() . "', $memberID)", __FILE__, __LINE__);
db_query("
INSERT INTO {$db_prefix}buddies
(ID_MEMBER, BUDDY_ID, approved, position, time_updated, requested)
VALUES ($memberID, 2, 0, 1, '" . time() . "', 2)", __FILE__, __LINE__);
// Post a PM about the Buddy request
require_once $sourcedir . '/Subs-Post.php';
// Set up the PM message array
$pmfrom = array(
'id' => 2,
'name' => 'Forum Admin',
);
// send the PM :)
sendpm (array('to' => array($memberID), 'bcc' => array()), sprintf ($txt['buddy_notif_new_subject'], $pmfrom['name']), sprintf ($txt['buddy_notif_new_body'], $pmfrom['name'], $scripturl . '?action=buddies'), false, array ('id' => 0, 'name' => $txt['profile_notif_com_user'], 'username' => $txt['profile_notif_com_user']));
// end of auto post on profile
NOTE ID for admin on my forum is 2, so one needs to change that to correct ID for the admin at your forum
Thanks a lot Sinan :D
Not at all. Marking the topic as solved. ;)
Huston, we have a problem :D :D :D
The hack works great, but there is ONE THING that does not work, and that is, the users that do accept being added to buddies to Admin, does NOT show up at the Admins buddy list...
(but admin shows at THEIR buddy list)
anyone have any idea how to fix? :)
If it helps, the new added users show up in the OLD buddy list for Admin (the original buddy list for SMF) but not in Ultimate profiles
index.php?action=profile;u=2;sa=editBuddies Works... Shows the new buddies for Admin
But they dont show up at ultimate profile buddies ::)
If it helps anyone smart, here is a script how to move buddies from OLD original SMF buddy list, to the new Ultimate Profile buddy list (but its a bit greek to me.. lol )
function MigrateBuddies() {
global $db_prefix, $context;
// How many to migrate at once?
$num_at_once = 50;
$context['start'] = (int)$_POST['start'];
$context['start'] = (isset ($context['start'])) ? $context['start'] : 0;
// Count members
$request = db_query ('SELECT COUNT(ID_MEMBER) FROM ' . $db_prefix . 'members', __FILE__, __LINE__);
list ($members_count) = mysql_fetch_row ($request);
$request = db_query ('SELECT ID_MEMBER, buddy_list FROM ' . $db_prefix . 'members ORDER BY ID_MEMBER ASC LIMIT ' . $context['start'] . ', ' . $num_at_once, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc ($request))
$members[] = $row;
$context['start'] += $num_at_once;
$context['percentage_done'] = round(($context['start'] * 100) / $members_count, 2);
foreach ($members as $member) {
$buddies = explode (',', $member['buddy_list']);
foreach ($buddies as $buddy_id) {
if ($buddy_id == '')
continue;
$request = db_query ('SELECT requested FROM ' . $db_prefix . 'buddies WHERE ID_MEMBER = ' . $member['ID_MEMBER'] . ' AND BUDDY_ID = ' . $buddy_id, __FILE__, __LINE__);
if (mysql_num_rows ($request) < 1) {
// Find the new position.
$request = db_query ('SELECT position FROM ' . $db_prefix . 'buddies
WHERE ID_MEMBER = ' . $member['ID_MEMBER'] . '
ORDER BY position DESC
LIMIT 1', __FILE__, __LINE__);
list ($position) = mysql_fetch_row ($request);
$position = $position + 1;
db_query ('INSERT INTO ' . $db_prefix . 'buddies SET ID_MEMBER = ' . $member['ID_MEMBER'] . ', BUDDY_ID = ' . $buddy_id . ', approved = 0, position = ' . $position . ', time_updated = "' . time() . '", requested = ' . $member['ID_MEMBER'], __FILE__, __LINE__);
$request = db_query ('SELECT position FROM ' . $db_prefix . 'buddies
WHERE ID_MEMBER = ' . $buddy_id . '
ORDER BY position DESC
LIMIT 1', __FILE__, __LINE__);
list ($position) = mysql_fetch_row ($request);
$position = $position + 1;
db_query ('INSERT INTO ' . $db_prefix . 'buddies SET BUDDY_ID = ' . $member['ID_MEMBER'] . ', ID_MEMBER = ' . $buddy_id . ', approved = 0, position = ' . $position . ', time_updated = "' . time() . '", requested = ' . $member['ID_MEMBER'], __FILE__, __LINE__);
}
}
}
// Still more to do?
if ($members_count > $context['start'])
{
MigrateTemplate();
return;
}
MigrateDone();
}
Well, it would be better if you ask the rest from JovanT.
When I finally had some time to look into it, the fix wasnt too hard to find...
The code also needs to add into database at the ID of the admin, that he/she requested the new user, and not only on the ID of the new user getting a request... In other words the auto requests needs to be inserted TWO times into the database, BOTH for admin doing the request, and to the new user getting the request...
Or else Aproved = 1 will not find it for the admin's request, and the buddy not show up at his/her list :)
So here is the fully working final code :) And all creds and thanx to Sinan
Anyone wanting to use the code rembeber to replace the ID = 2 for the user YOU want to send from & add buddy from (your admin ID usually)
EDIT : Updated for a contect bug, thanx to F.L.A.M.E.R for spotting :)
../Sources/Register.php
Find:
$memberID = registerMember($regOptions);
// Auto Post at profile mod
loadLanguage('UltimateProfile');
db_query("
INSERT INTO {$db_prefix}profile_comments
(ID_MEMBER, comment, time, COMMENT_MEMBER_ID)
VALUES (2, 'Hi there<br>Welcome to our community!<br>Hope you enjoy the stay, and come back often :)', '" . time() . "', $memberID)", __FILE__, __LINE__);
// insert the buddy request to the new member in DB
db_query("
INSERT INTO {$db_prefix}buddies
(ID_MEMBER, BUDDY_ID, approved, position, time_updated, requested)
VALUES ($memberID, 2, 0, 1, '" . time() . "', 2)", __FILE__, __LINE__);
// also insert the request at admins side so that approved buddy will show up right
// We want to find last used position at admins buddy list first
global $db_prefix;
$result = db_query("SELECT position FROM {$db_prefix}buddies WHERE `ID_MEMBER` = 2
ORDER BY `position` DESC
LIMIT 0 , 1 ", __FILE__, __LINE__);
$position = mysql_fetch_assoc($result);
$position = $position["position"];
$position = $position + 1 ;
// insert the admins buddy request with position last on the buddy list
db_query("
INSERT INTO {$db_prefix}buddies
(ID_MEMBER, BUDDY_ID, approved, position, time_updated, requested)
VALUES (2 , $memberID , 0, '" . $position . "', '" . time() . "', 2)", __FILE__, __LINE__);
// Post a PM about the Buddy request ?
require_once $sourcedir . '/Subs-Post.php';
// Set up the PM from name - Change this to your own likings
$pmfrom = 'Forum Admin';
// send the PM :)
sendpm (array('to' => array($memberID), 'bcc' => array()), sprintf ($txt['buddy_notif_new_subject'], $pmfrom), sprintf ($txt['buddy_notif_new_body'], $pmfrom, $scripturl . '?action=buddies'), false, array ('id' => 0, 'name' => $txt['profile_notif_com_user'], 'username' => $txt['profile_notif_com_user']));
// end of auto post on profile
Congrats runebergen, you did it. ;)
*cough* *cough*
Here is what appears up when the last and final code is added in
Parse error: syntax error, unexpected T_STRING in /home/stalkers/public_html/Sources/Register.php on line 382
Where line 382 is
sendpm (array('to' => array($memberID), 'bcc' => array()), sprintf ($txt['buddy_notif_new_subject'], $pmfrom), sprintf ($txt['buddy_notif_new_body'], $pmfrom, $scripturl . '?action=buddies'), false, array ('id' => 0, 'name' => $txt['profile_notif_com_user'], 'username' => $txt['profile_notif_com_user']));
This error appears up when the user goes to registration page...
Edit:-
I didnt know i would find out what the error maybe but here it is.
on this line in the code by runebergen.
$pmfrom = 'Forum Admin";
There is a " instead of '
Just replace it and it all works fab..
So in short.. Replace:-
$pmfrom = 'Forum Admin";
With
$pmfrom = 'Forum Admin';
Have fun..!
Just minor problems i suppose, after doing this, I am getting these 3 errors in the error log.
8: Undefined index: member
File: /home/stalkers/public_html/Themes/default/languages/Post.english.php (before sub template - eval?)
Line: 107
8: Undefined index: member
File: /home/stalkers/public_html/Themes/default/languages/Post.english.php (before sub template - eval?)
Line: 106
8: Undefined index: member
File: /home/stalkers/public_html/Themes/default/languages/Post.english.php (before sub template - eval?)
Line: 105
All from the link:-
http://hackerzden.com/index.php?action=register
So any solution ?
Ehm... BUMP..!
It doesn't use 'member' index anywhere. At least the one I gave. Are you sure that they are cause of these codes?
ehm.. they came up after these codes where added.. maybe some other admin must have added some other mod with errors.. Most probably.. it should be due to this one...
Okay, remove the codes and try again. If you get the same errors, then attach your Register.php file here.
ok, let me try it again.. I will be back here shortly..
I'm not getting these errors here :)
The mod/hack works just fine... :)
And thanx for fixing the ".." error... I changed that part live here, when posting (to remove my own admin name), so wrote up wrong ... it should of course be ' ' :D
Updated the code above, for the "" bug :)
Finally.. I found where the error came from.. I added the field of birthdate on to the registration page which i think caused this error.. I actually cannot figure it out but please help me out with this..
It maybe the register.php or register.template.php
I have more doubt in register.template.php
Can you just check it out for me please. And well.. the newly registered member actually gets the buddy request himself.. i did the edits on the 1st page but didnt get it right..
Files Attached:-
register.php
register.template.php
Register.template.php
Find:
<input type="text" name="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '" tabindex="', $context['tabindex']++, '" /> -
<input type="text" name="bday1" size="2" maxlength="2" value="', $context['member']['birth_date']['month'], '" tabindex="', $context['tabindex']++, '" /> -
<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '" tabindex="', $context['tabindex']++, '" />
Replace:
<input type="text" name="bday2" size="2" maxlength="2" tabindex="', $context['tabindex']++, '" /> -
<input type="text" name="bday1" size="2" maxlength="2" tabindex="', $context['tabindex']++, '" /> -
<input type="text" name="bday3" size="4" maxlength="4" tabindex="', $context['tabindex']++, '" />
The last codes runebergen have given should be working, have you tried them?
Just a small favour with this, Can you make this as a drop down to select the date in the "Birthday Form" ? As this is a bit crazy thing which will confuse some users causing irritation in the minds of the users.. rather drop down would be better.. Please...?
This is what I've came across in Turkish Language Support board:
<tr>
<td width="40%">
<b>Birthday:</b>
<div class="smalltext">Day-Month-Year</div>
</td>
<td>
<select name="bday2" tabindex="', $context['tabindex']++, '" />
<option>Day</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>-
<select name="bday1" tabindex="', $context['tabindex']++, '" />
<option>Month</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select> -
<select name="bday3" tabindex="', $context['tabindex']++, '" />
<option>Year</option>
<option>1950</option>
<option>1951</option>
<option>1952</option>
<option>1953</option>
<option>1954</option>
<option>1955</option>
<option>1956</option>
<option>1957</option>
<option>1958</option>
<option>1959</option>
<option>1960</option>
<option>1961</option>
<option>1962</option>
<option>1963</option>
<option>1964</option>
<option>1965</option>
<option>1966</option>
<option>1967</option>
<option>1968</option>
<option>1969</option>
<option>1970</option>
<option>1971</option>
<option>1972</option>
<option>1973</option>
<option>1974</option>
<option>1975</option>
<option>1976</option>
<option>1977</option>
<option>1978</option>
<option>1979</option>
<option>1980</option>
<option>1981</option>
<option>1982</option>
<option>1983</option>
<option>1984</option>
<option>1985</option>
<option>1986</option>
<option>1987</option>
<option>1988</option>
<option>1989</option>
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>1993</option>
<option>1994</option>
<option>1995</option>
<option>1996</option>
<option>1997</option>
<option>1992</option>
<option>1999</option>
<option>2000</option>
</select>
</td>
</tr>
/me has a feeling this question is not really related to this topic.
Thanks for that fix runebergen :)
I was gonna leave it so I didnt have the user asking to be a buddy, with HEAPS of buddies in his list! lol
But figured someone might get too sensitive not seeing their name there lol
Quote from: [SiNaN] on August 23, 2008, 05:52:11 PM
/me has a feeling this question is not really related to this topic.
*Sabre's thinking {SiNaN} maybe right!
lol
Thank you, Lets see if i get everything right with all the queries.. I will be back with some more problems.
Edit:-
You forgot to close the code.. a '; is missing at the end..it gave me template parse error
Quote from: [SiNaN] on August 23, 2008, 05:52:11 PM
/me has a feeling this question is not really related to this topic.
/me supports this feeling but doesnt want to wait much for some good helpers to help out later on
Well, it depends the place you pasted those codes. It doesn't have an openning, so doesn't need a closing too. :P
well i dont know what was wrong lolz.. just added those things and it started working... i pasted over the older code which was there in the register.template.php before for the normal forms..