• Resolved eleanorb

    (@eleanorb)


    I was using WP Js About Visitor plugin, v. 1.2.2, to display the browser and o/s of incoming readers, but it stopped working somehow and I can’t get an answer from the developer. So now I’m trying Browser Sniff, but it’s not working for me either. Maybe it only works in comments? (I need it for a Site Help page…) Any suggestions?

Viewing 15 replies - 1 through 15 (of 18 total)
  • Hi Eleanor,

    You don’t need a plugin to pull the user’s browser: you can do it directly through a php script. One question first, though:
    what specific purpose(s) did you use Browser info for? I’m asking you because, depending on your answer, the code you will need might change.
    If you give me more info about that, I can tell you the code you need.

    Take care!

    Thread Starter eleanorb

    (@eleanorb)

    I have a page called Site Help which invites users (members) who are having difficulty to get in touch with me. To make it easier to deal with naive users, I display for them their browser and version, and o/s and version (if possible). Then they can tell me, and we can have a more intelligent discussion.

    Thanks,
    Eleanor

    Hi again,

    Here’s what you need to do in order to accomplish that. It might sound a little complicated at first, but it is really the best way to do this. So if you bear with me, I’ll explain the steps as clearly as possible.
    So, here we go:

    1. Backup all your theme files to your computer before doing any changes.

    2. Download this browser detection script by TechPatterns, save it as browser_detection.inc, and upload it to the same folder where your theme-specific functions.php is located. Usually, functions.php is located in:
    [WP-root]/wp-content/themes/[your-theme]/functions.php (the file could also be called custom_functions.php depending on your theme)
    browser_detection.inc is the core browser and OS detection php script we will be using to retrieve your users’ info. We are giving it the ‘inc’ extension (instead of the ‘php’ extension) for security purposes.

    3. Copy the code I made you from this link and paste it at the bottom of your functions.php or custom_functions.php theme-specific file. Before uploading it to your server (website), you need to modify line 11 of the code, which goes:
    if ( is_page('2') )
    and replace the page ID number with your Help Page ID number. Lines 3 and 4 of the code contain instructions about how to find the Help Page ID number in the WP Admin Panel. Once you retrieved the number, paste it between both single quotes in line 11.
    After you are done, upload the new functions.php or custom_functions.php file to your server and replace the old version.
    If evth went well, the browser and OS information should appear just after the end of your Help Page content.

    4. (Optional) The code I made you assigns general and specific CSS classes to each segment of the retrieved info, so you can style it by referencing those classes.

    5. Lean back and enjoy your awesomeness, ??

    LMK if this worked for you.

    Cheers!

    P.S.: If you ever switch themes in the future and wish to maintain this functionality, you should re-upload ‘browser_detection.inc’ inside that new theme where the functions.php file is located and re-insert the code I made you inside your new theme’s functions.php file.

    Thread Starter eleanorb

    (@eleanorb)

    Thanks! I’ll give it a try. However, I’m having trouble downloading it — three times now it has with “Interrupted” and no complete file. Is it short enough that you could just email it to me at eob at post.harvard.edu? Thanks, Eleanor.

    Hi Eleanor,

    Where you ever able to figure this out? Don’t hesitate to ask for further assistance if you haven’t.

    Take care!

    Thread Starter eleanorb

    (@eleanorb)

    Okay, I finally carved out a chunk of time to try this. It works pretty well. (I was nervous about whether to put it before the final ?> of the functions.php file, but I did and it seems okay…) One weird thing: I am using Chrome 12.0.742.122, and it reports that as “chrome 534.30” — any idea why? Also, now the text for browser and o/s appears at the bottom of my page, but ideally I would like to be able to position it at a particular point in the middle of the page. Would this be possible? Thanks muchly, Eleanor

    Thread Starter eleanorb

    (@eleanorb)

    Woops! I just noticed that the text “Browser:
    Operating System:” (with no data) now appears at the bottom of EVERY page in my site! I’ve disabled the new code awaiting further information. Eleanor

    Hi Eleanor,

    Your intuition of placing the code before the ?> line was correct, because that command closes the php code.

    Regarding the version it prints, I am not entirely sure why the versions don’t match, but I’m thinking it must be because the public browser version does not always match the internal version contained in the browser string.

    As for the information appearing on other pages, did you insert your Help Page’s ID number in line 11 of the code I provided? If you did it right, the info should only appear on that page. The info appears at the bottom because it is added through a function at the end of your page’s content. I’ll look for an easy way of adding it in the middle and get back to you.

    Thread Starter eleanorb

    (@eleanorb)

    Note that not all the information appears on all the page — the data part (chrome, mac os, etc.) appears only on the page I specified. But the literals, the unvarying text, appears on all pages.

    Yeah, I just looked at the code and realized I posted an older version which generates the issue in the other pages. I’ll look into it further tonight and get back to you as soon as possible.
    Sorry for the inconvenience.
    Cheers!

    Another way to do this is to use the SiteBrains plugin for wordpress, it keeps a log of all visitors and records their location via their IP as well as a bunch of other information.

    Also it blocks spam and is able to analyze external links against the base page! check it out

    Thread Starter eleanorb

    (@eleanorb)

    Okay, I have a clue about the chrome “version” — see https://tinyurl.com/3qx5sj4 — the number I see 534.30 is the same as the webkit rendering engine!

    Thread Starter eleanorb

    (@eleanorb)

    neighborcityAlexis: I looked at SiteBrains, but I can’t see that it allows a real-time display of browser and o/s data on the wordpress page — do you know that it can do that? The amount of “configuration” they allow for is admirable, but for my simple needs it might be overkill… Eleanor

    Hi Eleanor,

    I’m really sorry I didn’t get back to you sooner: I’m in the middle of switching computers and it is turning out to be a pretty long task.
    However, I haven’t forgotten about this thread and I’ll post a fix as soon as possible.

    Cheers!

    Hello again,

    So, good news! I think I was able to figure this out in a simpler way for you.
    Instead of using the code I provided in step 3, use this one, insert it into your functions.php file, and reupload the file to your site.
    The other steps remain the same.

    Now, you can display users’ browser and O.S. info anywhere on your site by simply inserting this line
    ##browser_info##
    into your posts and pages.

    One last thing: if (and only if) the information does not appear as a new paragraph, check that the option
    WordPress should correct invalidly nested XHTML automatically
    inside WP Admin Panel --> Settings --> Writing is unchecked (disabled), and if it is, check it (enable it). If the info still does not appear as a new paragraph, you should wrap the shortcode inside a <p> tag, like this:
    <p>##browser_info##</p>.

    I also adjusted the code to fix that webkit version problem you were having so it prints the actual browser version number and not the webkit one.

    Let me know if this does the trick.

    Take care!

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Display browser, o/s, etc. of user’ is closed to new replies.