Skip to:

Plugin to show user IP and current date

  • piyaliguha90


    Hi I am creating a website with BBPress. but Need a plugin which show current user IP, Current time of user below of my website.

Viewing 2 replies - 1 through 2 (of 2 total)
  • For the current ip, you can add this function to your child theme or have it in a plugin:

    function get_the_user_ip() {
    if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
    //check ip from share internet
    $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
    //to check ip is pass from proxy
    } else {
    $ip = $_SERVER['REMOTE_ADDR'];
    return apply_filters( 'wpb_get_ip', $ip );
    add_shortcode('show_ip', 'get_the_user_ip');

    Then use a shortcode [show_ip] where needed

    For the current time of where the user is (so NOT where the server is), you can only do it with javascript to my knowledge. Start from this:

    <script language="javascript">
    ourDate = new Date();
    document.write("The time and date at your computer's location is: "
    + ourDate.toLocaleString()
    + ".<br/>");
    document.write("The time zone offset between local time and GMT is "
    + ourDate.getTimezoneOffset()
    + " minutes.<br/>");
    document.write("The time and date (GMT) is: "
    + ourDate.toGMTString()
    + ".<br/>");


Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar