Support » Plugins » Adding HTTP:// To Comment URIs

  • Resolved tsguitar


    If a visitor comes to my site, leaves a comment, but doesn’t type http:// before his address in the URI box, when I view that person’s comment, the link to their site is broken. WordPress doesn’t add http:// to their link if it isn’t there and without it their link won’t work.

    Am I missing something that I can to turn on? Is there a convenient way to add that? I don’t mind editing WP files, but if there’s a plugin for this, I appreciate the tip. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • There is no setting for it. You’ll probably have to alter the comments.php file for your theme to check for the “http://” portion in the URI and add it if it’s not there.


    Any ideas about how I’d do that? Using comment_author_link(), which is both the URL and the commenter’s name, doesn’t really allow me to do much with it.

    I tried:
    $url = str_replace("http://","",comment_author_link());
    // take it out if it is there
    $url1 = str_replace("www","http://www", $url);
    // since none of them have it, add it in to every one
    echo $url1;

    That didn’t work. Any other ideas about how to check for the http:// and add it if it’s not there?

    Try replacing comment_author_link() with this:

    echo preg_replace('%href=([\"|\'])(?!http://)%i', "href=$1http://", get_comment_author_link());

    The regular expression used above in preg_replace() matches an href value *not* beginning http:// and inserts that into the output.

    That does it. Nice job, as always, Kafkaesqui. It works perfectly. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding HTTP:// To Comment URIs’ is closed to new replies.