• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Can you set a profile field selection in a template?

Phases

Active member
#1
I'm wondering, can I do this:

Link that already does stuff <-- click, it does stuff. I'd like it to also set profile_field = "Yes" on click.

Another link that already does stuff <-- click, it does its stuff, but I'd like it to also set profile_field = "No" on click.

?
 

Phases

Active member
#3
Currently it slides open a box, the slides it back closed. Just like the "Thread Display Options" accordion dropdown.

I'm hoping with some trickery I can pull off a "set profile field x to yes" at the same time.
 

Jeremy

Well-known member
#7
A xen:callback is inappropriate here. It won't be able to accomplish what he wants.

If the JavaScript is custom already, add in a simple jQuery selector to find the input and inverse it's value.
 

Phases

Active member
#8
I'm not sure I'm following, I was hoping for more of a explanation than that - I barely follwed - but I'll google it and see if I can figure it out. jQuery selector.. got it.
 

AndyB

Well-known member
#9
I'm wondering, can I do this:

Link that already does stuff <-- click, it does stuff. I'd like it to also set profile_field = "Yes" on click.

Another link that already does stuff <-- click, it does its stuff, but I'd like it to also set profile_field = "No" on click.

?
When you say "profile_field", do you mean a Custom User Field?
 

AndyB

Well-known member
#11
Link that already does stuff <-- click, it does stuff. I'd like it to also set profile_field = "Yes" on click.

Another link that already does stuff <-- click, it does its stuff, but I'd like it to also set profile_field = "No" on click.

?
You can add PHP code to the "Link that already does stuff" to update the Custom User Field. You need to select the database and have a query update the correct table.
 

Jeremy

Well-known member
#13
Andy, you cannot use PHP to change the value on a page after it's loaded. Regardless, unless the link that "expands a box and already does stuff" causes a new page load, you cannot use PHP and will have to use JavaScript.
 

Phases

Active member
#14
Dern. I would be able to figure out PHP lol.

Imaging the "Thread Display Options" dropdown when viewing threads in a forum. You know how you can click it to scroll it down, then click again to scroll it up. I use another block elsewhere using code based from that, it does the same thing. I want to update a custom profile field from fiend 1 to field 2 when expanding, then back from field 2 to field 1 when closing. Pretty much explains it. I could sort php/sql, but JS would be a challenge for me.