Help with error messages

Discussion forum for MOD Writers regarding MOD Development.
Locked
Jhonne
Registered User
Posts: 21
Joined: Sat Feb 27, 2010 7:36 pm

Help with error messages

Post by Jhonne » Mon Aug 01, 2011 5:46 am

The default for the forum when triggering errors is that the error message is loading on a new page with the message_body.html. However, during login errors there is a code snippet in functions making them load on the same page. Like when a user enters wrong logion information.

In functions.php

Code: Select all

		// Something failed, determine what...
		if ($result['status'] == LOGIN_BREAK)
		{
			trigger_error($result['error_msg']);
		}

		// Special cases... determine
		switch ($result['status'])
		{
			case LOGIN_ERROR_ATTEMPTS:

				$captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']);
				$captcha->init(CONFIRM_LOGIN);
				// $captcha->reset();

				$template->assign_vars(array(
					'CAPTCHA_TEMPLATE'			=> $captcha->get_template(),
				));

				$err = $user->lang[$result['error_msg']];
			break;

			case LOGIN_ERROR_PASSWORD_CONVERT:
				$err = sprintf(
					$user->lang[$result['error_msg']],
					($config['email_enable']) ? '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') . '">' : '',
					($config['email_enable']) ? '</a>' : '',
					($config['board_contact']) ? '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">' : '',
					($config['board_contact']) ? '</a>' : ''
				);
			break;

			// Username, password, etc...
			default:
				$err = $user->lang[$result['error_msg']];

				// Assign admin contact to some error messages
				if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD')
				{
					$err = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>');
				}

			break;
		}
And in login_body.html

Code: Select all

<!-- IF LOGIN_ERROR --><div class="error">{LOGIN_ERROR}</div><!-- ENDIF -->
I tried to make something like this working in the includes/ucp/ucp_remind.php file but have failed so far. Anyone knows what i can do to make this working?

I want to have the error message when submitting wrong information on the send password page to load at the same page just like it do on the login page.

Thanks for any help,

Locked

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