The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
Some time ago, after much messing about, I managed to get the code in THIS thread to work on my live site.
What this does is change the style chooser dropdown (for members) so that instead of setting a cookie, it actually updates the user profile. However, despite replicating the template code exactly using vB4-style variables, I can't get it to work. It seems to submit the form but redirects back to index.php instead of staying on the page it was on, but doesn't actually change the style. That suggests that the $show['member'] conditional is returning false, but even if I totally remove that conditional and just leave the code to be executed on submitting the form, it still does the same thing. I've tried comparing the code with other files in vB4 and it seems correct, so I can't work out what's missing. I'm sure it's something simple. Here's the contents of my file myprofile.php: Code:
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'myprofile'); define('CSRF_PROTECTION', true); // ######################### REQUIRE BACK-END ############################ require_once('./global.php'); // ############################### start update options ############################### if ($_POST['do'] == 'updateoptions') { if ($show['member']){ $vbulletin->input->clean_array_gpc('p', array('newstyleset' => TYPE_INT)); $userdata =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD); $userdata->set_existing($vbulletin->userinfo); // style set if ($vbulletin->options['allowchangestyles'] AND $vbulletin->userinfo['realstyleid'] != $vbulletin->GPC['newstyleset']) { $userdata->set('styleid', $vbulletin->GPC['newstyleset']); } ($hook = vBulletinHook::fetch_hook('profile_updateoptions')) ? eval($hook) : false; $userdata->save(); } else { exec_header_redirect("../index.php?"); } } // ############################################################################# $url = $_SERVER['HTTP_REFERER']; exec_header_redirect($_SERVER['HTTP_REFERER']); ?> Code:
<vb:if condition="$show['quickchooser']"> <vb:if condition="$bbuserinfo['userid']"> <form style="display: inline" action="myprofile.php" method="post" > <input type="hidden" name="s" value="" /> <input type="hidden" name="do" value="updateoptions" /> <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" /> <select class="forumselector" name="newstyleset" id="sel_newstyleset" onchange="this.form.submit()";> <optgroup label="{vb:rawphrase quick_style_chooser}"> {vb:raw quickchooserbits} </optgroup> </select> </vb:if> </vb:if> Can anybody spot what needs changing? If pointed in the right direction I'm sure I'm savvy enough to sort it! |
#2
|
||||
|
||||
![]()
Two things.... first, you didn't put it inside the other form that is originally there, did you? Also, I think you mean onchange="this.form.submit();"
|
#3
|
|||
|
|||
![]()
Thanks Lynne...I knew you'd suss it! It was inside the other form, I forgot about the language chooser (which I don't use).
I also changed the onchange code on the live 3.8 site too, although it was working, the syntax was clearly wrong. All working now. |
#4
|
||||
|
||||
![]()
Great!
![]() |
#5
|
|||
|
|||
![]()
I'm pleased about this one, I have never liked the "cookie based" system of style choosing, it confuses people. I am never sure quite why vB have stuck with it for so long.
Cookie based is fine for guests but not for members. |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|