MyBB Community Forums

Full Version: Show When Registered
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a string of code to show when you(the user) registered?
Where do you want to display it?
It's a plugin, edited version of hello world.
This should do the trick then:

my_date($mybb->settings['regdateformat'], $post['regdate']);
It's part of another string of text so I included it in the same bit and used: {$mybb->settings['regdateformat']} and it just shows M Y. See http://zingor.net/mybbprofessor/
{$mybb->settings['regdateformat']} is the date format you set in Admin CP. And you can't use {$post['regdate']} because it only works in the postbit (and even then it would only output a timestamp). So you need to use the my_date() function to format that timestamp into a readable date, according to the date format you set in the Admin CP.

Store that in a variable and call it in your code. That simple.
Okay so what needs to be edited and added?

Source code:
<?php
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: hello.php 5440 2011-04-15 10:18:35Z Tomm $
 */
 
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("pre_output_page", "hello_world");

function hello_info()
{
	/**
	 * Array of information about the plugin.
	 * name: The name of the plugin
	 * description: Description of what the plugin does
	 * website: The website the plugin is maintained at (Optional)
	 * author: The name of the author of the plugin
	 * authorsite: The URL to the website of the author (Optional)
	 * version: The version number of the plugin
	 * guid: Unique ID issued by the MyBB Mods site for version checking
	 * compatibility: A CSV list of MyBB versions supported. Ex, "121,123", "12*". Wildcards supported.
	 */
	return array(
		"name"			=> "Hello World",
		"description"	=> "A sample plugin that prints hello world and prepends the content of each post to 'Hello world!'",
		"website"		=> "http://mybb.com",
		"author"		=> "MyBB Group",
		"authorsite"	=> "http://mybb.com",
		"version"		=> "1.0",
		"guid" 			=> "",
		"compatibility" => "*"
	);
}

/**
 * ADDITIONAL PLUGIN INSTALL/UNINSTALL ROUTINES
 *
 * _install():
 *   Called whenever a plugin is installed by clicking the "Install" button in the plugin manager.
 *   If no install routine exists, the install button is not shown and it assumed any work will be
 *   performed in the _activate() routine.
 *
 * function hello_install()
 * {
 * }
 *
 * _is_installed():
 *   Called on the plugin management page to establish if a plugin is already installed or not.
 *   This should return TRUE if the plugin is installed (by checking tables, fields etc) or FALSE
 *   if the plugin is not installed.
 *
 * function hello_is_installed()
 * {
 *		global $db;
 *		if($db->table_exists("hello_world"))
 *  	{
 *  		return true;
 *		}
 *		return false;
 * }
 *
 * _uninstall():
 *    Called whenever a plugin is to be uninstalled. This should remove ALL traces of the plugin
 *    from the installation (tables etc). If it does not exist, uninstall button is not shown.
 *
 * function hello_uninstall()
 * {
 * }
 *
 * _activate():
 *    Called whenever a plugin is activated via the Admin CP. This should essentially make a plugin
 *    "visible" by adding templates/template changes, language changes etc.
 *
 * function hello_activate()
 * {
 * }
 *
 * _deactivate():
 *    Called whenever a plugin is deactivated. This should essentially "hide" the plugin from view
 *    by removing templates/template changes etc. It should not, however, remove any information
 *    such as tables, fields etc - that should be handled by an _uninstall routine. When a plugin is
 *    uninstalled, this routine will also be called before _uninstall() if the plugin is active.
 *
 * function hello_deactivate()
 * {
 * }
 */


function hello_world($page)
{
  global $mybb;
  $page = str_replace("<div id=\"content\">", "<div id=\"content\"><p>Your username is {$mybb->user['username']} and you registered on </p>", $page);
    return $page;
} 

?>
Try this:

<?php
/**
* MyBB 1.6
* Copyright 2010 MyBB Group, All Rights Reserved
*
* Website: http://mybb.com
* License: http://mybb.com/about/license
*
* $Id: hello.php 5440 2011-04-15 10:18:35Z Tomm $
*/

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("pre_output_page", "hello_world");

function hello_info()
{
    /**
     * Array of information about the plugin.
     * name: The name of the plugin
     * description: Description of what the plugin does
     * website: The website the plugin is maintained at (Optional)
     * author: The name of the author of the plugin
     * authorsite: The URL to the website of the author (Optional)
     * version: The version number of the plugin
     * guid: Unique ID issued by the MyBB Mods site for version checking
     * compatibility: A CSV list of MyBB versions supported. Ex, "121,123", "12*". Wildcards supported.
     */
    return array(
        "name"            => "Hello World",
        "description"    => "A sample plugin that prints hello world and prepends the content of each post to 'Hello world!'",
        "website"        => "http://mybb.com",
        "author"        => "MyBB Group",
        "authorsite"    => "http://mybb.com",
        "version"        => "1.0",
        "guid"             => "",
        "compatibility" => "*"
    );
}

/**
* ADDITIONAL PLUGIN INSTALL/UNINSTALL ROUTINES
*
* _install():
*   Called whenever a plugin is installed by clicking the "Install" button in the plugin manager.
*   If no install routine exists, the install button is not shown and it assumed any work will be
*   performed in the _activate() routine.
*
* function hello_install()
* {
* }
*
* _is_installed():
*   Called on the plugin management page to establish if a plugin is already installed or not.
*   This should return TRUE if the plugin is installed (by checking tables, fields etc) or FALSE
*   if the plugin is not installed.
*
* function hello_is_installed()
* {
*        global $db;
*        if($db->table_exists("hello_world"))
*      {
*          return true;
*        }
*        return false;
* }
*
* _uninstall():
*    Called whenever a plugin is to be uninstalled. This should remove ALL traces of the plugin
*    from the installation (tables etc). If it does not exist, uninstall button is not shown.
*
* function hello_uninstall()
* {
* }
*
* _activate():
*    Called whenever a plugin is activated via the Admin CP. This should essentially make a plugin
*    "visible" by adding templates/template changes, language changes etc.
*
* function hello_activate()
* {
* }
*
* _deactivate():
*    Called whenever a plugin is deactivated. This should essentially "hide" the plugin from view
*    by removing templates/template changes etc. It should not, however, remove any information
*    such as tables, fields etc - that should be handled by an _uninstall routine. When a plugin is
*    uninstalled, this routine will also be called before _uninstall() if the plugin is active.
*
* function hello_deactivate()
* {
* }
*/


function hello_world($page)
{
  global $mybb;

  $example = my_date($mybb->settings['regdateformat'], $post['regdate']);

  $page = str_replace("<div id=\"content\">", "<div id=\"content\"><p>Your username is {$mybb->user['username']} and you registered on {$example}</p>", $page);
  
  return $page;
} 

?>
Awesome it works thanks Big Grin

+Rep