Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Mayhem30 on July 19, 2011, 06:13:25 PM

Title: If <first post> and user id = <id>
Post by: Mayhem30 on July 19, 2011, 06:13:25 PM
I've been working on a small little project - and was wondering if someone could help me with the last part.

I only want my code snippet to show if :

1) it's the first post in a thread
2) User id = 6 (me)

SMF 1.1.14 (2.0 example would be great as well)

Thank you.
Title: Re: If <first post> and user id = <id>
Post by: Matthew K. on July 19, 2011, 06:16:52 PM
if ($message['id'] == $context['first_message'] && $context['user']['id'] === 6)
Title: Re: If <first post> and user id = <id>
Post by: Mayhem30 on July 19, 2011, 06:21:22 PM
That was fast.

Thanks  :)
Title: Re: If <first post> and user id = <id>
Post by: Matthew K. on July 19, 2011, 06:34:25 PM
Not a problem, good luck with your project :) Thanks for marking the topic resolved, by the way
Title: Re: If <first post> and user id = <id>
Post by: Mayhem30 on July 26, 2011, 02:04:03 AM
The code bit only shows if I'm logged in (won't display code to guests or other users).

How would I fix this?
Title: Re: If <first post> and user id = <id>
Post by: ascaland on July 27, 2011, 11:36:20 AM
If you want it so everyone can see it and its the first message, then use this if statement,
if ($message['id'] == $context['first_message'])
Title: Re: If <first post> and user id = <id>
Post by: cicka on July 27, 2011, 11:43:05 AM
Quote from: Mayhem30 on July 26, 2011, 02:04:03 AM
The code bit only shows if I'm logged in (won't display code to guests or other users).

How would I fix this?

In your first post you wanted the code to show only to your user id and it's the first post in a thread. And that is exactly what the code posted above by Labradoodle-360 does.

Now you are asking something different. It would help if you were more precise in what you wanted :)
Title: Re: If <first post> and user id = <id>
Post by: Mayhem30 on July 27, 2011, 02:24:34 PM
Sorry, I didn't explain myself clearly in my first post.

What I want to do is add some custom links (and other stuff) under my avatar - but I only want the stuff to show if it's the first post in a thread - and only on my profile (but I would like it to be visible to everyone).
Title: Re: If <first post> and user id = <id>
Post by: Mayhem30 on July 29, 2011, 10:20:46 PM
So ... is this not possible?
Title: Re: If <first post> and user id = <id>
Post by: Matthew K. on August 04, 2011, 08:57:07 PM
This is definitely possible, right now, I am on a trip, and when I get back, I'll post the code for you.
Title: Re: If <first post> and user id = <id>
Post by: Jokerâ„¢ on August 05, 2011, 08:30:52 AM
Try this

if ($message['id'] == $context['first_message'] && $message['member']['id'] == 1)