Hero Inc.

where heroes are an everyday occurrence


2 domains, 1 host

Yeah, I ripped the title of this post from the infamous viral video (probably NSFW, wiki link) but it was funny and worked well here.

For those who have been following me somewhat, I recently joined into a venture of sorts with friends in order to post our many movie reviews collectively under a single banner known as The Amateur Critics Guild.  It was a simple idea and tons of fun to actually build the branding, especially the About page, which still cracks me up when I look at it.

Anyway, back to the original purpose in this post.  We needed a domain for the site and finally settled on theacguild.net because we liked the name and it was available.  Mostly it was available.  We only wanted to pay for the domain and not the hosting since my current site, this one, was probably only using about 30% of its full capacity.  We knew we could just forward the domain and be done with it.

I setup wordpress for The ACG within a new directory on my site and set the forwarding rule through my provider (1and1).  The site was up and running, but one glaring issue continued to bother me as the URL of the site would always be something like “heroinc.org/theacguild/<some post naming structure>”.  This may have been a cheaper route than purchasing more hosting space but I knew that I had not had this issue earlier when I had the domain apenguinandme.com.  After a few bad attempts, here’s how to have it work so you can have 2 domains and 1 host (recursion anyone?).

Setup The Second Domain

  1. Buy the second domain.
  2. Within the domain, setup a forwarding rule.  1and1 allowed me 2 options for forwarding the domain:  1)  Provide a url, 2) Provide a home directory for the domain.
  3. Choose the option to “provide a home directory for the domain”.  Option 1 would just forward the url and you would always have “domain1.com/domain2directory” for your website.  Option 2 allows for “domain2.com” and “domain1.com” without anyone needing to know the difference.

1and1 Screenshot

I assume that the option of forwarding to a particular directory will only work if the domains are purchased from the same hosting company where the site is hosted. I could be wrong on that, but I doubt it.

Now that the forwarding is setup, you are good to go.  However, what if you were like me and setup the wordpress site improperly the first time?  Well, good thing I did this first for you.  Here’s how you correct your wordpress installation.

Bad WordPress Installation Fix
Perform these steps during offhours for your site so that you don’t cause problems if issues come up.

  1. Backup the database associated with wordpress installation.  I’m always a fan of backing up so that you can revert back to the original if things go wrong.
  2. Backup the wordpress directory where wordpress is installed.  Like I said, I’m a fan of backups.
  3. Within the admin page of your wordpress installation, navigate to the Settings / General page.
  4. Change the “WordPress address (URL)”.  For example, before mine was “http://heroinc.org/theacguild”.  After I updated it, it said “http://theacguild.net”.
  5. Change the “Site address (URL)”.  Same example as before.  Mine was “http://heroinc.org/theacguild”.  After I updated it, it said “http://theacguild.net”.
  6. Save the changes.  The site might act up for a second but don’t worry about it.
  7. NEXT STEPS ARE DANGEROUS WHICH IS WHY WE TOOK BACKUPS.  If you skipped steps 1 and 2, do them NOW.  I’ll wait….
  8. Navigate to the database for your wordpress installation.  With my site, I use phpMyAdmin.
  9. Use the search function to query the database tables for the old domain name.  The returned tables from the search all need to be updated to remove the old references so that all of your site links work.

  10. Using a sql query, you can do a quick replace throughout the database table. The following sql query will do the replace for you and it should be repeated for each table that was returned by the query. Just remember that the query will replace all instances and that may not be what you always need so use caution. I know that I had a post or two on the new site where I linked to my actual real site and I had to manually make those changes so not to override what my post was meant to use.
  11. Within your wordpress installation directory, search for “olddomain.com”. I believe it was within 4 of my files (404.php, header.php, sidebar.php, and style.css).
  12. Within each returned file from the search, do a find and replace to change “olddomain.com” to “newdomain.com”.
  13. Finally, in the words of the great wordpress instructions, go do something nice for yourself as you are now finished in updating your site to properly use the new domain.

Here’s hoping this will help other people who made a stupid mistake like I did.

Posted under Internet | Tagged as , , ,

No More Facebook Comments

Four score and many months ago, I attempted to help out in fixing a wordpress plugin that I wanted for my site.  In an effort to reach more people to share my stupidity and no real depth or knowledge, I wanted to utilize Facebook’s notes to pull my blog posts to Facebook and then pull any comments posted there back to my website.

After a few successful tries, I started to slowly realize that something was not quite right with Facebook.  The constant change of the site’s HTML made the plugin become a complete waste after a week of quality use after every fix.  I soon decided to take my last effort and release it back to the wordpress community for them to continue updating if desired.

Since releasing it back to others, I’ve always secretly wanted someone to find a solution.  Well, I’m now here to say I don’t want anyone to fix it.  Instead if people want to post to the facebook population, then just use the status messages and inform friends to exit from facebook for a great read.

Facebook, knowingly and purposefully make these consistent changes to the site’s design in order to deter any developers in coding solutions that will crawl the site for any data that Facebook does not allow one to receive via their APIs.  The reason for this has nothing to do with preventing your identity from being taken away from Facebook for security purposes.  They just want full control so that they can exploit the identity and sell the data for their profit as well as force users to stay within the Facebook walls in order to dictate what the web experience can and will be.

Therefore, until Facebook changes their current stance and opens the API to allow access to specific information externally for enhancing the social interaction outside of Facebook, my limited (and terrible developing) skills will not be used for pushing my traffic into Facebook, but to push Facebook traffic out.

Facebook, you are doing it wrong

Posted under Internet | Tagged as , ,

0.38D Facebook Comments

Don’t get your hopes up WordPress users. I have not fixed the Facebook Comments plugin. I’ve received countless comments and emails regarding the plugin so I decided the best I could do for now is to aid the community by passing out more of the work I have performed in order to get this plugin working.

Currently, the plugin pulls back information from Facebook for the Notes comments, but the values stored in the WordPress database are not correct because of the regular expressions used and Facebook’s constant HTML updates.

However, I have added a feature so that you can see what the plugin does return in order to give a way of visually testing the plugin without harming your WordPress database. Hopefully someone else can take a look at the plugin, much like I did originally, and offer a solution. Keep the community updated on changes and fixes and perhaps we can get this plugin going again. If you find fixes, I’ll add them here or update with links to your own site.

Change Log;

  • 0.38D – July 30, 2009 – Let’s term this version as D for Development. It’s far from working that it isn’t good enough for a Beta or Alpha label for now. Utilizing the “Test Import” function one can see what the plugin returns from Facebook.

Update for April 30, 2010: I have decided to end all development and future development related to this plugin. The reasoning for this change can be found here. I have closed the ability to post comments to this post and hope any further comments will be directed at my reasoning post.

Posted under Internet | Tagged as , ,

0.34 Facebook Comments

One of the latest WordPress plugins I have found is one used for Facebook. Facebook Comments will pull comments left on Facebook within the Notes application and import them into one’s WordPress blog. I’ve started using the Notes application lately and found it quite annoying that I could not keep my comments synced up in a single location. Well thanks to this plugin I can.

Except that now it is broken. Facebook Comments relies heavily on regular expressions to find the comments within the HTML of the Facebook page. Whenever the HTML is updated (which seems to happen often lately), a change to the Facebook Comments plugin is needed. The guy that originally wrote the plugin seems to be quite busy and wasn’t able to get around to a fix so I took a quick stab at it. Not only did I fix it (I think), I also added an additional feature that allows one to give a default url for all Facebook comment posters.

I haven’t been able to reach the original creator yet to offer my solution so I’ll post it here until he responds. Please enjoy it and let me know if you find any additional errors in it. I must state that my regular expression skills are nonexistent and I had to do the best that I could with my limited knowledge.

Change Log:

  • 0.36 – March 21 2009 – Due to the latest changes from Facebook, a few changes were needed for the plugin. I’m now posting my 0.36 version that I’ve tested locally. This will remove the extra link Facebook adds when a comment is too long. I did notice a new bug that deals with how Facebook changes links within comments, but that’s a fix for another day and time.
  • 0.35 – March 13 2009 – Due to the latest changes from Facebook, a few changes were needed for the plugin. I’m now posting my 0.35 version that I’ve tested locally.
  • 0.34 – March 01 2009

Update for April 30, 2010: I have decided to end all development and future development related to this plugin. The reasoning for this change can be found here. I have closed the ability to post comments to this post and hope any further comments will be directed at my reasoning post.

Posted under Internet | Tagged as , ,

No More WP Comment Emails

For those who have been around my site for sometime, you’ve known about my previous work creating my own CMS (Content Management System). I tried WordPress about 3 years ago and did not like it initially due to my limited knowledge of PHP and ability to change/modify functionality that it offered. However, I soon learned how much time I needed to truly build the CMS that would accomplish all of the tasks that I needed and I soon moved back to a happier WordPress time.

Well, after several months of WordPress usage, one minor detail has continued to grow on my nerves. WordPress can be setup to notify the author of the post of any comments that are made concerning the post. I had built this functionality into my own CMS but I stopped comments from being emailed if I made them. I mean, why would I want to read my own post comments? I only want to read those that others have left.

Since I had built this functionality before I knew it was possible. I just needed to take the time to find where I needed to make the change within WordPress. One night earlier this week, I finally took the time to find the file I needed to change and so far my change has worked. For those interested, here is what you need to do.

  1. Find the “comment.php” file in your WordPress files. It is listed under the “wp-includes” folder.
  2. Inside of this file you will need to find the “wp_new_comment” function. This is the function that inserts comments into the WordPress database. It also utilizes the PHP mail function to send mails to the author’s email address to notify of any new comments.
  3. Within the function, you will find the following IF statement that needs to be altered:
    if(get_option('comments_notify') && $commentdata['comment_approved'] &&
      $post->post_author != $commentdata['user_ID'])
         wp_notify_postauthor($comment_ID, $commentdata['comment_type']);

    This statement is saying to notify the post author if certain conditions are met. This function is great but we need to alter it so that for a particular case we do not notify the author.

  4. I modified my statement to be based on the email address since that is unique to an individual. Here is the changeI needed to make:
    if(get_option('comments_notify') && $commentdata['comment_approved'] &&
      $post->post_author != $commentdata['user_ID'] &&
      $commentdata['comment_author_email'] != 'username@myemail.com')
         wp_notify_postauthor($comment_ID, $commentdata['comment_type']);

    I basically added the extra condition that if everything else is right for emailing the author about the post that the system should make sure the commenter’s email address does not equal a certain value. For those that might try it on my site, the email address above is not the one I used on the code change for Hero Inc. I just wanted to provide an example here.

That’s it. That’s all that needed to change for the emails to stop when I posted comments on my own posts. When I made this coding change, I also modified a few other sections of my site that were bugging me as well. Namely the comments section was changed from the design perspective. I have hated for a long time how the comments were displayed using an ordered list of numbers.

Let me know if you do or do not like the latest comment design changes. Man, it was nice to code for “fun” again.

Posted under Internet | Tagged as