| The Arcive of vBulletin Modifications Site. | |
| 
			 
			#1  
			
			
			
			
			
		 | |||
| 
 | |||
|  Call Vars from vBulletin into Plugin and echo them in a template 
			
			I want to apply the "substr()" function to one of the custom profile fields. I will display the modified field in my postbit. I am trying to display the last two characters of the college graduation year in the postbit as follows: College 'YR. I know I have to create a plugin calling in the field4 (college graduation year) variable, apply the substr() function, and create a new variable to echo in my template. My plugin is as follows: Code: $vbulletin->profilefieldname[field4] = $collgrad; 
$collgradtruncated = substr($collgrad, 2); 
$mytemplater = vB_Template::create('mytemplate'); 
$mytemplater->register('my_str', $my_str); 
$myrendervar = $mytemplater->render(); 
vB_Template::preRegister('postbit_legacy',array('myrendervar ' => $myrendervar));Code: <vb:if condition="$post['field4']"><dt>{vb:rawphrase college}</dt> <dd>{vb:raw post.field4} '{vb:raw collgradtruncated}</dd></vb:if>1) how to call profile field values in my plugin 2) setup a variable in my plugin that I can use in my template 3) tell me what is wrong with my code 4) fix the code for me Thank you so much! | 
| 
			 
			#2  
			
			
			
			
			
		 | |||
| 
 | |||
|   
			
			I think what you want for the first line is: Code: $collgrad = $post['field4']; But I think maybe you just want to do this: Code: $collgradtruncated = substr($post['field4'], -2); 
vB_Template::preRegister('postbit_legacy',array('collgradtruncated' => $collgradtruncated));then in the template you can use {vb:raw collgradtruncated} for the two digit year. You didn't say which hook location you're using. | 
| 
			 
			#3  
			
			
			
			
			
		 | |||
| 
 | |||
|   
			
			Thanks Kevin. I'm using global_start. The code you supplied doesn't function. Do I need to add something else? | 
| 
			 
			#4  
			
			
			
			
			
		 | |||
| 
 | |||
|   
			
			If I understand what you're doing, you want to put the college year info in the postbit, so you want it to be the post author's year?  Then you need to use a hook location that is called once per post, before it's rendered, like postbit_display_complete.
		 | 
| 
			 
			#5  
			
			
			
			
			
		 | |||
| 
 | |||
|   
			
			Awesome! That worked great! Thanks so much for the help!
		 | 
|  | 
| 
 | 
 | 
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
| 
 | |
|  More Information | |
| Template Usage: 
 Phrase Groups Available: 
 | Included Files: 
 Hooks Called: 
 |