so far I tried the following:
editing the ActivationEmail-Plugin by adding this to the part /* activation */
$results = $modx->runSnippet('ExtUserRegisterProfile', $fields);
Then I modified my ExtUserRegisterProfile-snippet and commented out some lines:
//$submission = isset($_POST['login-updprof-btn']) && ($_POST['login-updprof-btn'] == $modx->lexicon('login.update_profile'));
...
...
...
//if ($submission) {
$modx->request->sanitizeRequest();
$dirty = false;
foreach ($fields as $key => $value) {
if (isset($_POST[$key])) {
if ($value !== $_POST[$key]) {
$data->set($key, $_POST[$key]);
$dirty = true;
}
}
}
if ($dirty) {
$data->save();
}
//}
I thought by doing this the snippet won't rely on the submit-button.
The activation itself still works, mails gets sent to the user; but my hope to get those two fields written to the DB-table did not work.
Another way I tried was to directly implement the content of my ExtUserRegisterProfile-snippet into the ActivationEmail-Plugin, right below this line:
$eventName = 'activate_user';
I added this:
/**
* ExtUserUpdateProfile snippet for ClassExtender extra
*
* Copyright 2012-2014 by Bob Ray <http://bobsguides.com>
* Created on 03-23-2014
*
* ClassExtender is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* ClassExtender is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* ClassExtender; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*
* @package classextender
*/
/**
* Description
* -----------
* Set placeholders for and update extended user data
*
* Variables
* ---------
* @var $modx modX
* @var $scriptProperties array
*
* @package classextender
**/
$modx->lexicon->load('login:updateprofile');
//$submission = isset($_POST['login-updprof-btn']) && ($_POST['login-updprof-btn'] == $modx->lexicon('login.update_profile'));
$data = null;
//$user = null; - commented out because $user got set before in the ActivationEmail-plugin
//$fields = array(); - commented out because $fields-array got set before in the ActivationEmail-plugin
/* @var $data userData */
if (isset($modx->user) && ($modx->user instanceof modUser)) {
$user =& $modx->user;
$data = $modx->getObject('userData',
array('userdata_id' => $user->get('id')), false);
if ($data) {
$fields = $data->toArray();
} else {
$data = $modx->newObject('userData');
if ($data) {
$data->set('userdata_id', $user->get('id'));
$fields = $data->toArray();
}
}
}
if (! is_array($fields) || empty($fields)) {
return '';
}
/* Convert any nulls to '' */
if (!empty($fields)) {
foreach($fields as $key => $value) {
if (empty($value) && ($value !== '0')) {
$fields[$key] = '';
}
}
$modx->setPlaceholders($fields);
}
//if ($submission) {
$modx->request->sanitizeRequest();
$dirty = false;
foreach ($fields as $key => $value) {
if (isset($_POST[$key])) {
if ($value !== $_POST[$key]) {
$data->set($key, $_POST[$key]);
$dirty = true;
}
}
}
if ($dirty) {
$data->save();
}
//}
return '';
The user-ID gets set earlier in the original ActivationEmail-Plugin by this:
So I thought this part needs to be modified:
if (isset($modx->user) && ($modx->user instanceof modUser)) {
$user =& $modx->user;
$data = $modx->getObject('userData',
array('userdata_id' => $user->get('id')), false);
if ($data) {
$fields = $data->toArray();
} else {
$data = $modx->newObject('userData');
if ($data) {
$data->set('userdata_id', $user->get('id'));
$fields = $data->toArray();
}
}
}
Before I edited this part I tried it by using the script without furhter editing, but no success again.
Then I changed the above part to that:
if (isset($modx->user) && ($modx->user instanceof modUser)) {
$user =& $modx->user;
$data = $id;
if ($data) {
$fields = $data->toArray();
} else {
$data = $modx->newObject('userData');
if ($data) {
$data->set('userdata_id', $user->get('id'));
$fields = $data->toArray();
}
}
}
But then the activation didn't work anymore.
After that I tried:
$data = $dbUser;
Activation works, but no entry in DB-table...
last thing I tried was to remove the part completely, but nah...
So for now I got back to the original ActivationEmail-Plugin...so further try'n'error needed...