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

18 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 (158 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 (158 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
neoandini (1 comments)

Thanks For the solution man…………..

3 December 09 at 23:21
isdaryanto (2 comments)

please test in my blog..it’s OK or NOT..thnks..

6 December 09 at 01:06
Randy Brown (158 comments)

@isdaryanto – i still see the errors when i posted a comment

6 December 09 at 01:10
isdaryanto (2 comments)

Hi randy..i’m sorry..you’re very fast to visit in my blog but i did’nt finish yet to edit this theme..hahaha..so please visit my blog again.. i hope that fix for errors..i like your creativity to make bottom bar with image..tell me if you find this script to make bottom bar..thnks

6 December 09 at 01:23
Phele Anderesta (1 comments)

thank your blessing father is my web pleases, almost i am mahu install comes his theme. 5 my times has failed and appear problem likes this.

13 December 09 at 07:19

loving the template. Really a facebook feel.

15 December 09 at 14:43
blacky (1 comments)

Dude, you totally rule! God bless you, you saved my day! Enjoy he Christmas vacation ;)

20 December 09 at 12:32

Awesome work Randy! Even the author still got the same problem as i tried to post comment in his web. Almost give up till I found your powerfull code. You deserve a Best Christmas time.. Our warmest regards..

24 December 09 at 13:08
jon (2 comments)

Hey Randy great site ya got there, just wondering how do ya manage to be able to add so much text in the comments box? On my site I am unable to add as much text as you, any ideas ? Thanks mate

14 January 10 at 17:35
jon (2 comments)

Hey Randy, your code about the odd # that was messing things up, that is brill. Your fix worked great, I used it to fix my problems.Tope bloke Randy

14 January 10 at 17:40
Randy Brown (158 comments)

@Jon: i never had any trouble with the amount of text in the comment box so I dont know what might be causing that on your site.

14 January 10 at 18:44
Travis (3 comments)

Hey Randy, wow man you seem like a super helpful dude. Much appreciation for taking the time to help everyone out like this. Quick question… I can’t get MY avatar to show up. I’ve set it up at Gravatar.com but it isn’t pulling the picture when I post or comment on my own blog, like yours is. I’m using the same email address that’s in my WP General Settings section. Any guesses what would be up with it?

23 April 10 at 11:41
Randy Brown (158 comments)

@Travis.. well.. that’s odd.. are other people’s Gavatars showing, and only yours isnt, are, are NO Gravatars showing?

23 April 10 at 11:48
Travis (3 comments)

Hey Randy. Your quick man. Yeah, other peoples are showing… just not mine. Can’t be anything big I’m thinking. I was just thinking that maybe there’s some other place I’m supposed to put my email address or something.

23 April 10 at 11:50
Randy Brown (158 comments)

I assume you’re using the newest version of Smells Like Facebook. After some Googling, i’m seeing that others are having the same trouble with Gravatars displaying as you, so i assume it’s a bug in the newer version. I’m still using and older version (i’m afraid to upgrade!). You may want to try clearing your browser-cache in the event you’re just not seeing it yourself. Post a link to your blog and i’ll let you know how it looks from my end..

23 April 10 at 11:57
Travis (3 comments)

Thanks Randy for spending time on this little issue for me! Not too many people around like that. I’ve been looking around too and it looks like I’m slightly retarded and set my gravatar to Rated PG and set the maximum rating at my blog to Rated G. All fixed now. Seems to be working, even with the upgraded version that I have. Thanks again man.

23 April 10 at 12:02
sms (1 comments)

thanks alot thanks..i just messed with that

15 June 10 at 11:12
Hristo (1 comments)

Hello! I have a little problem with this theme. I use Facebook like button and it is visible everywere, but not in categories. In first page is visible under every topic, but when I click on some category, there is no facebook like button under topics ( only in categories ) . Do you know why? And I have another problem – when someone like my post, activity ( ex. X likes X on X.com ) is visible only in personal profile, but not in News Feed and the traffic is so low. I see my friends, when like some link from webs ite ( with FB Like funktion ) , but in my blog, when someone like something, there is activity only on his/her profile, but not in news feed to his/her friends. Do you know why? Thank you a lot! Have a nice day!

26 June 10 at 00:10