How To Ensure That User Data To Be Saved Uppercase Letter?

I want that user adress data such as address line and name/sir name fields to be saved in uppercase letter while saving. How to do this? Which function should I use and where to make changes? Or on which controllers should I make changes?

[quote name='ooaykac' timestamp='1422030372' post='203309']

I want that user adress data such as address line and name/sir name fields to be saved in uppercase letter while saving. How to do this? Which function should I use and where to make changes? Or on which controllers should I make changes?

[/quote]



Use the update_user_pre hook which is located in the fn_update_user function

[quote name='eComLabs' timestamp='1422264949' post='203436']

Use the update_user_pre hook which is located in the fn_update_user function

[/quote]

Thanks eComLabs.



I want apply this change to all profile fields. What code should I use not to add all profile fields in codes?



function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
$user_data['b_address'] = strtoupper($user_data['b_address']);

return true;
}




I don't want add all profile fields here manually (line by line). How can I specify all profile fields with a shot code?

And if you place the strtoupper in the function.

Example:


function strtoupper(str) {
// example 1: strtoupper('Name);
// returns 1: 'NAME'
return (str + '')
.toUpperCase();
}


Hope this help you further.



Regards

[quote name='ooaykac' timestamp='1422299430' post='203490']

Thanks eComLabs.



I want apply this change to all profile fields. What code should I use not to add all profile fields in codes?



function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
$user_data['b_address'] = strtoupper($user_data['b_address']);

return true;
}




I don't want add all profile fields here manually (line by line). How can I specify all profile fields with a shot code?

[/quote]



Add the following string to find which fields should not be uppercased:



fn_print_r($user_data);




Then add a code similar to this:



foreach ($user_data as $k => $v) {
if (!is_array($v) && !in_array($k, array('first_key_to_skip', 'second_key_to_skip', 'etc'))) {
$user_data[$k] = strtoupper($v);
}
}

Thanks.

hi, i have created init.php and func.php in app/addons/my_changes with code

function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
		$user_data['b_address'] = strtoupper($user_data['b_address']);
return true;

}

but i can see any changes

hi, i have created init.php and func.php in app/addons/my_changes with code

function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
		$user_data['b_address'] = strtoupper($user_data['b_address']);
return true;

}

but i can see any changes

Hello,

Function name should be fn_my_changes_update_user_pre

hi, i have created init.php and func.php in app/addons/my_changes with code

function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
		$user_data['b_address'] = strtoupper($user_data['b_address']);
return true;

}

but i can see any changes

Also clear cache since used hooks are cached

nothing, any changes :-(

init.php


func.php

if ( !defined(‘AREA’) ) { die(‘Access denied’); }

function fn_my_changes_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{

$user_data['b_firstname'] = strtoupper($user_data['b_firstname']);	
$user_data['b_address'] = strtoupper($user_data['b_address']);	
$user_data['b_address_2'] = strtoupper($user_data['b_address_2']);
$user_data['b_city'] = strtoupper($user_data['b_city']);

return true;

}

?>

I want change text from lowercase to uppercase when users insert data from checkout step

i also clear cache and template

Please temporary add fn_print_r($user_data); to the function and check if this function is called. Debug information should be printed out to the screen

ok, it works only for registered users but not for guest users. why?

ok, it works only for registered users but not for guest users. why?

Yes, since mentioned function works with registered users only.

Additionally, you can use checkout.pre.php controller and change the $_REQUEST['user_data'] values in the update_steps mode