News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

username and profile link variables

Started by Duban Black, August 27, 2024, 08:16:31 PM

Previous topic - Next topic

Duban Black

Hi guys,
is there any variable that can be used to post the following values?
- username
- profile link

For example some mods like Custom form uses variables like this: {{Name}}

But I would like that when a person posts through my forms, this data is printed in the message. I need it to facilitate the work of the moderators of my forum.

I was looking in the templates, but variables like this: $message['member']['link'] do not print data.


Kindred

Can you please explain specifically what you are trying to accomplish?

It sounds like the custom form mod already does what you ask,  so why do your own code?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Duban Black

Of course, in the mod I have the following output configured:

[url={{Userlink}}]{{Avatar}} - {{Username}}[/url]
{{Avatar}} is the identifier of a form field.

What I need is to take the username, its profile link and post it as a response, for that I need to know if there is any variable in SMF that contains that data.

Kindred

I mean, there IS a variable in the code that has the value - that's how the mod fills it in to start with.

It's how quoting works...

However, the data is transient.  It's not always available and it's not always the same data...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Duban Black

Quote from: Kindred on August 27, 2024, 10:12:28 PMI mean, there IS a variable in the code that has the value - that's how the mod fills it in to start with.

It's how quoting works...

However, the data is transient.  It's not always available and it's not always the same data...

I think I did not explain well {{Userlink}} and {{Username}} they are an example. I need to get those variables somehow, I don't know how to get them.

Kindred

And I am asking WHY...

What is your end goal? What --specifically -- are you trying to do that you think you need that data?

  Because that will inform the answer.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

The problem is there's no central place to get them, but depending on you telling us what you're trying to do (rather than how you're trying to do it) it might be possible to get you going.
Holder of controversial views, all of which my own.


Duban Black

I need it to be displayed in a code so that moderators can copy and paste that information into a control post that manages the forum. The code has this structure:

[url=profilelink]{{Avatar}} - Username[/url]
{{Avatar}} is already collected with the form automatically, I just need to know with which variable I could grab the username and profile link.

For example if the form response was posted here from my account it should look like this:

[url=https://www.simplemachines.org/community/index.php?action=profile;u=290062]Matt lanter - duban1[/url]


Kindred

You are still not actually telling us what you are doing...

Quote from: duban1 on August 28, 2024, 09:29:15 AMI need it to be displayed in a code so that moderators can copy and paste that information into a control post that manages the forum.

Displayed where?? Copy from what/ what location?

QuoteThe code has this structure:

[url=profilelink]{{Avatar}} - Username[/url]
{{Avatar}} is already collected with the form automatically, I just need to know with which variable I could grab the username and profile link.

Again, the Code has that structure where?  Within the custom forms mod assembly of a post?

QuoteFor example if the form response was posted here from my account it should look like this:

[url=https://www.simplemachines.org/community/index.php?action=profile;u=290062]Matt lanter - duban1[/url]

Ok...  so, yes - from the customer form mod, that is a valid output post.

I still don't understand what you are trying to do that the custom forms mod is not already doing....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Duban Black

Quote from: Kindred on August 28, 2024, 09:40:12 AMYou are still not actually telling us what you are doing...
Displayed where?? Copy from what/ what location?
is shown in a post

Quote from: Kindred on August 28, 2024, 09:40:12 AMAgain, the Code has that structure where?  Within the custom forms mod assembly of a post?
the structure was defined by me in the output of the form

Quote from: Kindred on August 28, 2024, 09:40:12 AMOk...  so, yes - from the customer form mod, that is a valid output post.

I still don't understand what you are trying to do that the custom forms mod is not already doing....
the form captures the data that is entered in its fields, I don't need the mod to do something more specific, what I need is to obtain the system variables that contain the username and profilelink data of the user that posts, because I don't want to ask the user to enter those data manually, I want to obtain them automatically from the system.

Illori


Kindred

Illori,

I don't think that mod does anything like what the OP is asking.   That just allows wiki format BBC -- he'd still have to manually enter all of the data within the BBC.  WHat he's looking for (if I get it correctly now) is a way to automatically fill in the username and other details when the user adds a post via the custom form mod.

therefore, I am moving this out of 2.1 support and into coding help -- since this is outside of the core design
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Duban Black

Quote from: Kindred on August 28, 2024, 10:55:40 AMIllori,

I don't think that mod does anything like what the OP is asking.   That just allows wiki format BBC -- he'd still have to manually enter all of the data within the BBC.  WHat he's looking for (if I get it correctly now) is a way to automatically fill in the username and other details when the user adds a post via the custom form mod.

therefore, I am moving this out of 2.1 support and into coding help -- since this is outside of the core design

That's right, it would be two pieces of information: user name and profile link.

I could get it using javascript but I prefer to look for a way first using the information that SMF has stored.

Arantor

If there isn't a variable to send it from the custom form code, nothing else matters because you're coming at it from the wrong end.

It *has* to come from the custom form mod - and literally nothing else - when it assembles the post, because literally any other source of that data will be incorrect, because the post's owner is not available to the post content during bbcode rendering, so you can't just magically pull anything in.

Does the custom form mod not have an option to inject the poster's name at the point of creating the post?
Holder of controversial views, all of which my own.


Aleksi "Lex" Kilpinen

If I remember correctly, yes it does.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Duban Black

Quote from: Arantor on August 28, 2024, 11:04:54 AMIf there isn't a variable to send it from the custom form code, nothing else matters because you're coming at it from the wrong end.

It *has* to come from the custom form mod - and literally nothing else - when it assembles the post, because literally any other source of that data will be incorrect, because the post's owner is not available to the post content during bbcode rendering, so you can't just magically pull anything in.

Does the custom form mod not have an option to inject the poster's name at the point of creating the post?

I have searched through the mod options and it only injects the information entered manually in the form fields, nothing more than that.

Aleksi "Lex" Kilpinen

Is there a reason you need it IN the message? At least the version I've been using actually posts AS the user, if logged in.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Duban Black

Quote from: Aleksi "Lex" Kilpinen on August 28, 2024, 01:51:21 PMIs there a reason you need it IN the message? At least the version I've been using actually posts AS the user, if logged in.
yes, it must be inside the message because that data will be copied and pasted into a list that is used as a forum log.
It is part of an administrative task

Duban Black

I solved it using this code:

        $userId = $user_info['id'];
        $userName = $user_info['name'];
        $userProfileLink = $scripturl . '?action=profile;u=' . $userId;

        $replaceVars = [
            '*Username*' => $userName,
            '*Userlink*' => $userProfileLink,
        ];

        $output = str_replace(array_keys($replaceVars), array_values($replaceVars), $output);
resolved topic

Advertisement: