Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2012, 01:30 AM
basketmen's Avatar
basketmen basketmen is offline
 
Join Date: Nov 2006
Posts: 446
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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]);
Reply With Quote
  #2  
Old 04-14-2012, 07:55 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you may need to use
HTML Code:
$this->registry->userinfo['fieldx'])
where fieldx would be your field number like ['field 12']
Reply With Quote
Благодарность от:
SnakeV
  #3  
Old 04-15-2012, 09:23 PM
basketmen's Avatar
basketmen basketmen is offline
 
Join Date: Nov 2006
Posts: 446
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 04-15-2012, 10:32 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 04-16-2012, 12:45 AM
basketmen's Avatar
basketmen basketmen is offline
 
Join Date: Nov 2006
Posts: 446
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 04-16-2012, 12:51 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It wouldn't be $field1 but rather ['field1'] so the id of the field you are trying to manipulate
Reply With Quote
  #7  
Old 04-16-2012, 03:44 AM
basketmen's Avatar
basketmen basketmen is offline
 
Join Date: Nov 2006
Posts: 446
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #8  
Old 04-16-2012, 04:08 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you thought about leaving out you IF condition and see if you can get a replacement every time the hook is called?
Reply With Quote
  #9  
Old 04-16-2012, 04:30 AM
basketmen's Avatar
basketmen basketmen is offline
 
Join Date: Nov 2006
Posts: 446
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #10  
Old 04-16-2012, 05:24 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:58 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05253 seconds
  • Memory Usage 2,270KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_html
  • (8)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete