Learn Success With Randy Brown

Do it right the first time, stoopit.

Fix for ‘Smells-Like-Facebook’ theme error

After upgrading my WordPress and installing the new theme, “Smells Like Facebook” the first problem I ran into was errors anytime someone posted a comment:

Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/themes/smells-like-facebook/functions.php:12) in /home/mysite/public_html/wp-comments-post.php on line 82
Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/themes/smells-like-facebook/functions.php:12) in /home/mysite/public_html/wp-comments-post.php on line 83
Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/themes/smells-like-facebook/functions.php:12) in /home/mysite/public_html/wp-comments-post.php on line 84
Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/themes/smells-like-facebook/functions.php:12) in /home/mysite/public_html/success/wp-includes/pluggable.php on line 865

Seems that I’m not the only one having this problem, and the theme author appears to be busy, so I took it as a personal challenge to fix the damn thing myself. It only took 2 or 3 hours, but I think I got it. I’m posting it here for other people getting these annoying “Cannot modify header information – headers already sent” errors with the Smells Like Facebook theme.

WARNING:: I am not a coder.  I do not know what I am doing.  Before you attempt the changes below, back up your files, your Wordpress database, your email and all your iTunes music!  If you find that this ‘fix’ of mine breaks something else, please post a comment here.  I’ve been testing this fix for a few hours and as far as I can tell, it’s working – but I make no guarantees.

As indicated in the error message, the problem is in the functions.php file, at or about line 12, which reads:

add_filter('comment_text', 'slf_comment_text', 29);
function slf_comment_text($comment) {
echo str_replace("<br>", "<br/>", nl2br($comment));
}

The fix is to change that section to read:

add_filter('comment_text', 'slf_comment_text', 29);
function slf_comment_text($comment) {
if(empty($_POST['comment_post_ID'])) {
echo str_replace("<br>", "<br/>", nl2br($comment));
}
}

Like I posted above – this has worked for me so far.  If you find any problems please post them.

Applies to “Smells Like Facebook” Version 2.4

14 people like this post.

Categories: Blogging - PHP - Site Development
Coz (7 comments)

I am not able to find that text i the source for functions.php. (accessed via the admin screen, Appearance > Editor)

29 July 09 at 20:47
Coz (7 comments)

But it appears the comment did post successfully, here. Yours to me was flagged by askimet as spam for some reason.

29 July 09 at 20:48
Randy Brown (119 comments)

huh? that’s weird. I just re-downloaded the theme (ver 2.4) and confirmed it’s right there at line #12; something is fubar over there..

29 July 09 at 20:55
coz (7 comments)

Damn I shouldnt do this while talking Ambien. I kept commenting on the authors site.
Oh I was on 2.3. There hasn’t even been an announcement about 2.4, what the heck? Anyhow, I made the upgrade and then placed your hack into mine. This is your final test from me. Once more in return?

29 July 09 at 21:26
Nazieb (1 comments)

Thank you..


I’ll fix it in the next update..

29 July 09 at 23:46
Jonas Roque (1 comments)

Thanks for this!

6 August 09 at 15:06
WP Addict (1 comments)

Wew, Nazieb terkenal sampai disinih :D

7 August 09 at 20:38
Rajj (2 comments)

wow, that’s quite a coding. Can you translate that to HTML which i understand :)

12 August 09 at 01:11
Jessica Griffin (1 comments)

The coding looks quite complicated, but i love the theme! It looks just like a Facebook page.

13 August 09 at 02:40
clifford (1 comments)

wow thanks…iv been looking for this the who day

20 August 09 at 10:26
bali villas (1 comments)

Hi, Randy. It looks like your code is working.
Congrats.

25 August 09 at 01:50
yezet (1 comments)

Thanks for the solutions.
May I ask U something?
how to make “Like” and “share this” as your theme?
Thx alot

26 August 09 at 10:14
Randy Brown (119 comments)

The “Like” and “share this” are both Wordpress Plugins.. Just search the Wordpress Plugin repository and you’ll find several to choose from.

26 August 09 at 10:20
patricia (1 comments)

hey randy i would just like say that its a very great template,,, i would just like to ask if theres a blogger template like this…. thanks

8 September 09 at 03:32
Bivek (1 comments)

Hi thanku, i solved my problem with your solution.

16 September 09 at 02:08
Reon (1 comments)

It did it… Thanx, it work!!! Case closed! ^_^

26 September 09 at 18:24

it works like a charm…thank u man….

30 September 09 at 23:54

but something weird happen on my blog…when someone put a comment after they press submit, it goes to a blank screen and on the address bar it shows like this my original wordpress url.


I use different address between my wordpress folder and my blog apperance.


Can you tell whats wrong with it?

30 September 09 at 23:58
Mijk (1 comments)

…It is SAFE MODE ON issue, if you have SAFE MODE turned OFF, then this error doesn’t manifest itself…


Thanks for working patch!

1 October 09 at 11:55