vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Select user profile field inside a user profile field possible? (https://vborg.vbsupport.ru/showthread.php?t=289648)

Amit86 10-28-2012 12:37 PM

fields6 to 15 are not editable and are synced daily with my sql db

i want field 16 to be editable and to have it contain one of the fields from 6~15* (selectable by the member)

kh99 10-28-2012 01:59 PM

OK, so can you add the code I posted above (or something like it) to the code that does your daily syncing?

Amit86 10-28-2012 02:33 PM

Yeah, but what would be the point there if I want the member itself to choose which one of the players is his main player?

kh99 10-28-2012 02:40 PM

Because that would be the place to have any updates to fields 6-15 be reflected in the menu choices. The user would still need to go to their profile to choose main player.

Maybe I don't understand.

Amit86 10-28-2012 02:48 PM

Those fields are OK, I am trying to set up field16 to be choosable by the player
I want that field to be a SELECT field, the SELECT options would be the data inside field6(Rogue),field7(Mage),field8(etc),field9,fiel d10,field11,field12,field13,fi eld14,field15 which are not editable by the members..

kh99 10-28-2012 03:01 PM

I do understand that. But now I see that my idea wouldn't work because there is only one set of options in the database for a menu field, and you need each user to have their own, so it probably needs to be built when they go to edit their proifle.

OK, let me look in to that...

kh99 10-28-2012 04:36 PM

OK, I kind of figured it out, but it's not perfect. First create a menu with choices that are just the numbers 1 to 10 (or however many player slots you have). Then create a plugin using hook profile_fetch_profilefields and this code:

Code:

$menufield = 16; // id of menu field
$firstplayerfield = 6;  // id of first player field
$numplayers = 10;
if ($profilefield['profilefieldid'] == $menufield)
{
    global $vbulletin;
    $players = array();
    for ($i = 0; $i < $numplayers; $i++)
    {
        $fld = 'field' . ($i + $firstplayerfield);
        if (!empty($vbulletin->userinfo[$fld]))
        {
            $players[$i] = $vbulletin->userinfo[$fld];
            if (intval($vbulletin->userinfo['field' . $menufield]) == ($i + 1))
            {
                $vbulletin->userinfo['field' . $menufield] = $players[$i];
            }
        }
    }
    if (count($players))
    {
        $profilefield['data'] = serialize($players);
    }
}

This makes the settings page look OK, but the value being stored in the database is just a number 1-10. And when you go to view a user's profile, that number is displayed (although you get the right menu of choices if it's your profile and you edit the field by clicking the pencil). If you need the player name to be displayed in the profile instead of the number, it can probably be fixed using more plugins (but I don't have time to figure it out right now).

Amit86 10-28-2012 06:19 PM

1 Attachment(s)
Thank you for the kind help,
I have added your code to profile_fetch_profilefields and it works great!

Just need to continue working on this :)

sorry about the attach it was my misstake by reduplicating the plugin


All times are GMT. The time now is 04:33 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01099 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete