[For 1.8] Complete Guide to the ICQ Field Replacement
#1
***MyBB does not endorse or approve anything done below. Proceed at your own risk.***

This guide elaborates on information given in this thread:
https://community.mybb.com/thread-134852.html
Read that before attempting anything done below.

Say you want to change the ICQ field on your "Additional Contact Information" page to a Discord field, for instance.  You've changed the other contact fields to newfangled social media platforms like Facebook and Twitter, so of course this one should work the same way, right?

Alright, so you change the language files like normal, but this time you get an error.  You're perplexed!  Well, the reason that happens is because MyBB has a nice little integer check in a few places for the ICQ value.  Here's how to disable that check.

Notes:
- This tutorial involves editing the MySQL database through phpMyAdmin. If this daunts you, maybe don't do the things listed here or ask a friend for help.
- This is only tested in MyBB 1.8.13-14.
- I don't take responsibility for any damage you cause with this code to your files or forum.

Files modified:
- usercp.php
- /inc/datahandlers/user.php
- modcp.php

1. BACKUP THE FILES LISTED ABOVE, AND YOUR DATABASE.

2. Open usercp.php and make these changes:

- Replace this:
	foreach(array('icq', 'aim', 'yahoo', 'skype', 'google') as $cfield)
	{
		$csetting = 'allow'.$cfield.'field';
		if($mybb->settings[$csetting] == '')
		{
			continue;
		}

		if(!is_member($mybb->settings[$csetting]))
		{
			continue;
		}

		if($cfield == 'icq')
		{
			$user[$cfield] = $mybb->get_input($cfield, 1);
		}
		else
		{
			$user[$cfield] = $mybb->get_input($cfield);
		}
	}
with this:
	foreach(array('icq', 'aim', 'yahoo', 'skype', 'google') as $cfield)
	{
		$csetting = 'allow'.$cfield.'field';
		if($mybb->settings[$csetting] == '')
		{
			continue;
		}

		if(!is_member($mybb->settings[$csetting]))
		{
			continue;
		}
		
		$user[$cfield] = $mybb->get_input($cfield);
	}

- Replace this:
	if($user['icq'] != "0")
	{
		$user['icq'] = (int)$user['icq'];
	}

	if($user['icq'] == 0)
	{
		$user['icq'] = '';
	}

	if($errors)
	{
		$user['skype'] = htmlspecialchars_uni($user['skype']);
		$user['google'] = htmlspecialchars_uni($user['google']);
		$user['aim'] = htmlspecialchars_uni($user['aim']);
		$user['yahoo'] = htmlspecialchars_uni($user['yahoo']);
	}
with this:
	if($errors)
	{
		$user['icq'] = htmlspecialchars_uni($user['icq']);
		$user['skype'] = htmlspecialchars_uni($user['skype']);
		$user['google'] = htmlspecialchars_uni($user['google']);
		$user['aim'] = htmlspecialchars_uni($user['aim']);
		$user['yahoo'] = htmlspecialchars_uni($user['yahoo']);
	}

3. Open inc/datahandlers/user.php and make these changes:

- Find and delete this:
		if($this->method == "insert" || array_key_exists('icq', $user))
		{
			$this->verify_icq();
		}

- Replace this:
			"website" => $db->escape_string($user['website']),
			"icq" => (int)$user['icq'],
			"aim" => $db->escape_string($user['aim']),
			"yahoo" => $db->escape_string($user['yahoo']),
			"skype" => $db->escape_string($user['skype']),
			"google" => $db->escape_string($user['google']),
with:
			"website" => $db->escape_string($user['website']),
			"icq" => $db->escape_string($user['icq']),
			"aim" => $db->escape_string($user['aim']),
			"yahoo" => $db->escape_string($user['yahoo']),
			"skype" => $db->escape_string($user['skype']),
			"google" => $db->escape_string($user['google']),

- Replace this:
		if(isset($user['icq']))
		{
			$this->user_update_data['icq'] = (int)$user['icq'];
		}
with this:
		if(isset($user['icq']))
		{
			$this->user_update_data['icq'] = $db->escape_string($user['icq']);
		}

4. Open modcp.php and make this change:

- Find and delete this:
	if($user['icq'] != "0")
	{
		$user['icq'] = (int)$user['icq'];
	}

5. Save and quit, re-upload the files back to your server.

6. Open your MySQL database and go to the table titled "yourtableprefix_users".

7. Click the Structure tab and find the ICQ row (it should be #21).

8. Click the change button found in the ICQ row.

9. Change the value of "Length/Values" to your desired maximum character limit for the new type of field and click "Save."

10. OPTIONAL: MyBB saves a default value of 0 for the icq column. Click the SQL tab and enter this to clear all of the zeros:

UPDATE `yourtableprefix_users`
SET `icq` = ''
WHERE `icq` = '0';

That's it! Any questions can be put below.

@Staff: I'm not sure if anything here was against the rules. If it was, feel free to edit it out or delete the thread entirely.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)