vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Replace some characters in User Profile Field content (Many people should need it) (https://vborg.vbsupport.ru/showthread.php?t=281446)

basketmen 04-12-2012 01:30 AM

Replace some characters in User Profile Field content (Many people should need it)
 
I need to replace some characters in User Profile Field content,
for example aaa to be bbb


maybe there is two way, please help to make one of them or both works :




1. i see in User Profile Field Manager, there is regex function, what is the regex function patern to search and replace there?




2. or using a plugin with profile_updateprofile hook, but looks like below variable code in red are still wrong, so this is still not working


Quote:

$fieldcontentbefore = array(
'aaa',
'ccc'
);

$fieldcontentafter = array(
'bbb',
'ddd'
);


$vbulletin->user[$field] = str_replace($fieldcontentbefore, $fieldcontentafter, $vbulletin->user[$field]);

Simon Lloyd 04-14-2012 07:55 PM

I think you may need to use
HTML Code:

$this->registry->userinfo['fieldx'])
where fieldx would be your field number like ['field 12']

basketmen 04-15-2012 09:23 PM

thank you for replying, Simon Lloyd, i already tried it :
Quote:

$this->registry->userinfo['field1'] = str_replace($word, $link, $this->registry->userinfo['field1']);
but get this error message
Quote:

Fatal error: Using $this when not in object context in /home/username/public_html/profile.php(851) : eval()'d code on line 12


i already tried this too
Quote:

$vbulletin->registry->userinfo['field1'] = str_replace($word, $link, $vbulletin->registry->userinfo['field1']);
but nothing changed, from example, aaa still cant be bbb




please help guys, make this plugin working, or using regex function patern to search and replace in the profile fields

kh99 04-15-2012 10:32 PM

It might work if you use hook profile_start and code like this:

Code:

if ($_POST['do'] == 'updateprofile')
{
        $vbulletin->input->clean_gpc('p', 'userfield', TYPE_ARRAY);

        $fieldcontentbefore = array(
                'aaa',
                'ccc'
        );

        $fieldcontentafter = array(
                'bbb',
                'ddd'
        );


        $vbulletin->GPC['userfield'][$field] = str_replace($fieldcontentbefore, $fieldcontentafter, $vbulletin->GPC['userfield'][$field]);
}


but of course you need to set $field to something.

basketmen 04-16-2012 12:45 AM

thank you for replying too, i already tried the code and using profile_start hook

but its looks like still not working

do you mean change $field, to using field id like this right : $field1, or is it need other variable?

please help guys, i think this is basic thing that needed for vb, it will be rare characters that we want to replaced, but its should be patched too

Simon Lloyd 04-16-2012 12:51 AM

It wouldn't be $field1 but rather ['field1'] so the id of the field you are trying to manipulate :)

basketmen 04-16-2012 03:44 AM

Hmm i am afraid still not working

using this

Quote:

if ($_POST['do'] == 'updateprofile')
{
$vbulletin->input->clean_gpc('userfield', TYPE_ARRAY);

$fieldcontentbefore = array(
'aaa',
'ccc'
);

$fieldcontentafter = array(
'bbb',
'ddd'
);


$vbulletin->GPC[field1] = str_replace($fieldcontentbefore, $fieldcontentafter, $vbulletin->GPC[field1]);
}


or this



Quote:

if ($_POST['do'] == 'updateprofile')
{
$vbulletin->input->clean_gpc('userfield', TYPE_ARRAY);

$fieldcontentbefore = array(
'aaa',
'ccc'
);

$fieldcontentafter = array(
'bbb',
'ddd'
);


$vbulletin->GPC['field1'] = str_replace($fieldcontentbefore, $fieldcontentafter, $vbulletin->GPC['field1']);
}



how is it the code actually?

Simon Lloyd 04-16-2012 04:08 AM

Have you thought about leaving out you IF condition and see if you can get a replacement every time the hook is called?

basketmen 04-16-2012 04:30 AM

If you mean removing the if condition, i already tried it too


Quote:

$vbulletin->input->clean_gpc('userfield', TYPE_ARRAY);

$fieldcontentbefore = array(
'aaa',
'ccc'
);

$fieldcontentafter = array(
'bbb',
'ddd'
);


$vbulletin->GPC[field1] = str_replace($fieldcontentbefore, $fieldcontentafter, $vbulletin->GPC[field1]);


or this



Quote:

$vbulletin->input->clean_gpc('userfield', TYPE_ARRAY);

$fieldcontentbefore = array(
'aaa',
'ccc'
);

$fieldcontentafter = array(
'bbb',
'ddd'
);


$vbulletin->GPC['field1'] = str_replace($fieldcontentbefore, $fieldcontentafter, $vbulletin->GPC['field1']);



but still not replacing too, you can try it in your vb3 test site, or i can give a vb3 test site access if you like

kh99 04-16-2012 05:24 AM

Sorry, I left something out in the code I posted. It should have been:

Code:

        $vbulletin->input->clean_gpc('p', 'userfield', TYPE_ARRAY);

By the way, the reason that I thought profile_start would be better is that at profile_updateprofile the datamanager fields have been set already, so just doing a replace won't work.


All times are GMT. The time now is 03:50 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.01156 seconds
  • Memory Usage 1,748KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_html_printable
  • (8)bbcode_quote_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
  • (10)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