Nothing wrong with the code that I can see.
Try this:
<!--?php $oldProfile = isset($_SESSION['user_profile']) ? $_SESSION['user_profile'] : array(); $profile = $modx--->user->getOne('Profile'); if ($profile) { $newProfile = $profile->toArray(); } $output = ''; if (!empty($newProfile) && (!empty($oldProfile))) { foreach ($newProfile as $key => $value) { if ($oldProfile['key'] != $newProfile['key']) { $output .= ' ' . $key . ' changed from ' . $oldProfile['key'] . ' to ' . $newProfile['key']; } } } if (!empty($output)) { $output = ' Changes: ' . $output; } else { $output = ' Changes: none '; } if (! empty($output)) { die($output); } else { die('Output is empty'); } /* Change report will be in the $output variable here */ $modx->log(modX::LOG_LEVEL_ERROR, 'Profile update: $output' . $err); /* tell our snippet we're good and can continue */ return true;
<body> <br> "Changes: none" </br> </body>
foreach ($newProfile as $key => $value) { if ($oldProfile['key'] != $newProfile['key']) { $output .= ' ' . $key . ' changed from ' . $oldProfile['key'] . ' to ' . $newProfile['key']; }
foreach ($newProfile as $key => $value) { if ($oldProfile[$key] != $newProfile[$key]) { $output .= ' ' . $key . ' changed from ' . $oldProfile[$key] . ' to ' . $newProfile[$key]; }
<?php $oldProfile = isset($_SESSION['user_profile']) ? $_SESSION['user_profile'] : array(); $profile = $modx->user->getOne('Profile'); if ($profile) { $newProfile = $profile->toArray(); } $output = ''; if (!empty($newProfile) && (!empty($oldProfile))) { foreach ($newProfile as $key => $value) { if ($oldProfile[$key] != $newProfile[$key]) { $output .= ' ' . $key . ' changed from ' . $oldProfile[$key] . ' to ' . $newProfile[$key]; } } } if (!empty($output)) { $output = '<br />Changes:<br />' . $output; } else { $output = '<br />Changes: none<br />'; } if (! empty($output)) { die($output); } else { die('Output is empty'); } /* Change report will be in the $output variable here */ $modx->log(modX::LOG_LEVEL_ERROR, 'Profile update: $output' . $err); /* tell our snippet we're good and can continue */ return true;
$profile = $modx->user->getOne('Profile');
$profile = $modx->user->getOne('Profile', null, false);
[[!UpdateProfile? &preHooks=`SaveProfile` &postHooks=`CheckProfile`]]
/* SaveProfile snippet */ $profile = $modx->user->getOne('Profile'); $_SESSION['user_profile'] = empty($profile)? array() : $profile->toArray(); return true;
$oldProfile = isset($_SESSION['user_profile'])? $_SESSION['user_profile'] : 'No Profile'; $newProfile = $modx->user->getOne('Profile')->toArray(); $msg = ''; foreach($oldProfile as $key => $oldValue) { $newValue = empty($newProfile[$key])? '(empty)' : $newProfile[$key]; $oldValue = empty($oldValue)? '(empty)' : $oldValue; if ($newValue != $oldValue) { $msg .= "\n" . $key . ' changed from ' . $oldValue . ' to ' . $newValue; } } /* Email $msg here after debugging */ /* When through debugging, comment out these three lines */ $chunk = $modx->getObject('modChunk', array('name' => 'Debug')); $chunk->setContent($msg); $chunk->save(); return true;
[[!LogMeIn]]
/* LogMeIn snippet */ $modx->user->addSessionContext($modx->context->get('key')); return '';
extended changed from Array to Array