id: 87 name: saveSubscriber description: 'Snippet to save subscriber data for UpdateProfile' category: knit snippet: "/**\n * saveSubscriber snippet for knit extra\n *\n * Copyright 2021 by Iris Hammer iris.hammer@justknit.de\n * Created on 10-25-2021\n *\n * knit is free software; you can redistribute it and/or modify it under the\n * terms of the GNU General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option) any later\n * version.\n *\n * knit is distributed in the hope that it will be useful, but WITHOUT ANY\n * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n * A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License along with\n * knit; if not, write to the Free Software Foundation, Inc., 59 Temple\n * Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * @package knit\n */\n\n/**\n * Description\n * -----------\n * Snippet to save subscriber data for UpdateProfile\n *\n * Variables\n * ---------\n * @var $modx modX\n * @var $scriptProperties array\n *\n * @package knit\n **/\n\n\n$userId = $modx->getOption('user', $scriptProperties, '', true);\n$ks = $modx->getService('knitsubscription','KnitSubscription',$modx->getOption('knit.core_path',null,$modx->getOption('core_path').'components/knit/').'model/knit/',$scriptProperties);\nif (!($ks instanceof KnitSubscription)) {\n $message = '[JustKnit] Could not load KnitSubscription class';\n $modx->log(modX::LOG_LEVEL_ERROR,$message);\n return false;\n}\n$formFields = $hook->getValues();\n$modx->log(modX::LOG_LEVEL_ERROR,'$formFields
' .print_r($formFields, 1).'');\n\n$success = $ks->saveSubscriber($formFields,$scriptProperties);\n$fullname = $formFields['first_name'].' '.$formFields['last_name'];\n$fullname = trim($fullname);\n$modx->log(modX::LOG_LEVEL_ERROR,$fullname, $formFields['first_name'] ,$formFields['last_name'] );\n$hook->setValue('fullname',$fullname);\n\n\nreturn $success;" properties: 'a:0:{}' static: 1 static_file: core/components/knit/elements/snippets/savesubscriber.snippet.php ----- /** * saveSubscriber snippet for knit extra * * Copyright 2021 by Iris Hammer iris.hammer@justknit.de * Created on 10-25-2021 * * knit 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. * * knit 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 * knit; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA * * @package knit */ /** * Description * ----------- * Snippet to save subscriber data for UpdateProfile * * Variables * --------- * @var $modx modX * @var $scriptProperties array * * @package knit **/ $userId = $modx->getOption('user', $scriptProperties, '', true); $ks = $modx->getService('knitsubscription','KnitSubscription',$modx->getOption('knit.core_path',null,$modx->getOption('core_path').'components/knit/').'model/knit/',$scriptProperties); if (!($ks instanceof KnitSubscription)) { $message = '[JustKnit] Could not load KnitSubscription class'; $modx->log(modX::LOG_LEVEL_ERROR,$message); return false; } $formFields = $hook->getValues(); $modx->log(modX::LOG_LEVEL_ERROR,'$formFields
' .print_r($formFields, 1).''); $success = $ks->saveSubscriber($formFields,$scriptProperties); $fullname = $formFields['first_name'].' '.$formFields['last_name']; $fullname = trim($fullname); $modx->log(modX::LOG_LEVEL_ERROR,$fullname, $formFields['first_name'] ,$formFields['last_name'] ); $hook->setValue('fullname',$fullname); return $success;