-
Posts
991 -
Joined
-
Last visited
-
Days Won
3
Everything posted by PWaddict
-
[SOLVED] Creating user from api causes a weird issue
PWaddict replied to PWaddict's topic in General Support
Ok found why this is happening. The code is fine as I was I able to create a user from a different template and there was no problem. I'm creating a user when order through Padloper (v1) is completed. Few days ago I've renamed the page name "padloper" from the related admin page that displays the orders and since that name is hardcoded on Padloper module that's why I was getting that weird issue. -
[SOLVED] Creating user from api causes a weird issue
PWaddict replied to PWaddict's topic in General Support
It's on localhost with ProcessWire 3.0.251 and PHP 8.3.9. I've imported yesterday's db backup and the problem is gone. I did 2 things today, creating a custom process module and creating a user from api. The module doesn't cause any issue so I repeated the process of creating a user from the api and it seems that is causing the issue. Why the following code is causing that weird issue??? // Check if order is paid if($order->pad_paid) { // Save new user if($user->isGuest()) { $u = $users->add($order->email); $u->email = $order->email; $u->pass = $order->pass; $u->ip_address = $order->pad_ip_address; $u->addRole("login-register"); $u->save(); // Save user to the order page $order->setAndSave([ 'pad_user' => $u->id ]); } } -
Hello! I'm suddenly getting the following error on my first login to admin, when installing/uninstalling a module and when checking for new module updates through ProcessWireUpgrade module. PHP Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in C:\laragon\www\mysite\wire\core\LanguageFunctions.php on line 232 The line 232 of wire\core\LanguageFunctions.php has this: if($encode) $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8', $encode === true); And when this error happens, the main admin menu links Pages, Setup, Modules, Access are gone. EDIT: The following code on my template for creating user is causing that weird issue: // Check if order is paid if($order->pad_paid) { // Save new user if($user->isGuest()) { $u = $users->add($order->email); $u->email = $order->email; $u->pass = $order->pass; $u->ip_address = $order->pad_ip_address; $u->addRole("login-register"); $u->save(); // Save user to the order page $order->setAndSave([ 'pad_user' => $u->id ]); } }
-
@ryan @diogo @jploch are you planning to upgrade also the font awesome icons? They haven't been upgraded for over a decade... Few days ago the v7 was released. Last year I've created a module that upgrades backend with the latest Font Awesome free icons (solid + brands) but I think a core upgrade would be much better integration.
- 178 replies
-
- 11
-
-
Btw, if there are modules or hooks that send only plain text emails like for example some notifications on LoginRegisterPro with the following hook you can force HTML on all outgoing emails and forget about those ugly emails 😎 /** * Force HTML on all outgoing emails * */ $wire->addHookBefore('WireMail::send', function(HookEvent $event) { $wireMail = $event->object; if($wireMail->body && !$wireMail->bodyHTML) { $forceHTML = nl2br($wireMail->body); // nl2br — Inserts HTML line breaks before all newlines in a string $wireMail->bodyHTML($forceHTML); } }); I guess this can get combined with your hook but for now I'm using it as separate.
-
Thank you @bernhard for this! What if I have a LazyCron hook to send emails about expirations and want to display a call to action button on those? Should I create the button on a .mjml file then convert it to html and copy ONLY the HTML part of the button and paste it on BodyHTML of the LazyCron hook or there is a better way?
-
Here is the solution. First, on the checkbox field (let's call it terms_privacy_checkbox) settings leave empty the "Checkbox label". On the field "Label" you can either write something for example "Terms - Privacy Policy" or leave empty (it will output field name) doesn't matter cause we gonna remove it with the following hook. $wire->addHookAfter('Page::render', function(HookEvent $event) { if($this->wire('page')->template->name != 'checkout') return; $event->return = str_replace("<span class='pw-no-select'>Terms - Privacy Policy</span>","", $event->return); }); Then with the following hook where we customize our form we can change the markup for the checkbox field too and split it to 2 divs using for example UIkit. $wire->addHookBefore('InputfieldWrapper::render', function($event) { if ($this->wire('page')->template->name != "checkout") return; $wrapper = $event->object; $terms = wire('pages')->get("template=terms"); $privacy = wire('pages')->get("template=privacy"); $defaultMarkup = array( // Check wire\core\InputfieldWrapper.php for the $defaultMarkup 'list' => "<ul {attrs}>{out}</ul>", 'item' => "<li {attrs}>{out}</li>", 'item_label' => "<label class='InputfieldHeader ui-widget-header{class}' for='{for}'>{out}</label>", 'item_label_hidden' => "<label class='InputfieldHeader InputfieldHeaderHidden ui-widget-header{class}'><span>{out}</span></label>", 'item_content' => "<div class='InputfieldContent ui-widget-content{class}'>{out}</div>", 'item_error' => "<p class='InputfieldError ui-state-error'><i class='fa fa-fw fa-flash'></i><span>{out}</span></p>", 'item_description' => "<p class='description'>{out}</p>", 'item_head' => "<h2>{out}</h2>", 'item_notes' => "<p class='notes'>{out}</p>", 'item_detail' => "<p class='detail'>{out}</p>", 'item_icon' => "<i class='fa fa-fw fa-{name}'></i> ", 'item_toggle' => "<i class='toggle-icon fa fa-fw fa-angle-down' data-to='fa-angle-down fa-angle-right'></i>", // ALSO: // InputfieldAnything => array(any of the properties above to override on a per-Inputfield basis) // Here we override the default markup for checkbox field by targeting it's name 'name=terms_privacy_checkbox' => [ 'item_label' => "", 'item_label_hidden' => "", 'item_content' => " <div class='uk-grid-collapse{class}' uk-grid> <div class='uk-width-auto'> {out} </div> <div class='uk-width-expand'> <label class='uk-form-label' for='Inputfield_terms_privacy_checkbox'> <span class='uk-text-normal'>I agree with the <a href='{$terms->url}' rel='noopener' target='_blank'>{$terms->title}</a> and the <a href='{$privacy->url}' rel='noopener' target='_blank'>{$privacy->title}</a>.</span> </label> </div> {error} </div>", ], ); $defaultClasses = array( // Check wire\core\InputfieldWrapper.php for the $defaultClasses 'form' => '', // additional clases for InputfieldForm (optional) 'list' => 'Inputfields', 'list_clearfix' => 'ui-helper-clearfix', 'item' => 'Inputfield {class} Inputfield_{name} ui-widget', 'item_label' => '', // additional classes for InputfieldHeader (optional) 'item_content' => '', // additional classes for InputfieldContent (optional) 'item_required' => 'InputfieldStateRequired', // class is for Inputfield 'item_error' => 'ui-state-error InputfieldStateError', // note: not the same as markup[item_error], class is for Inputfield 'item_collapsed' => 'InputfieldStateCollapsed', 'item_column_width' => 'InputfieldColumnWidth', 'item_column_width_first' => 'InputfieldColumnWidthFirst', 'item_show_if' => 'InputfieldStateShowIf', 'item_required_if' => 'InputfieldStateRequiredIf' // ALSO: // InputfieldAnything => array(any of the properties above to override on a per-Inputfield basis) ); $wrapper->setMarkup($defaultMarkup); $wrapper->setClasses($defaultClasses); foreach ($wrapper->children as $in) { switch ($in->name) { case 'email': $in->wrapAttr('class', 'uk-width-1-1'); $in->addClass('uk-input'); $in->attr('required', 'required'); break; case 'pad_paymentmodule': $in->wrapAttr('class', 'uk-width-1-1 uk-margin-small-top'); $in->addClass('uk-radio'); break; case 'terms_privacy_checkbox': $in->wrapAttr('class', 'uk-width-1-1'); $in->addClass('uk-checkbox'); $in->attr('required', 'required'); break; case 'customerForm': $in->wrapAttr('class', 'uk-width-1-1 uk-margin-medium-top'); $in->addClass('uk-button uk-button-primary uk-button-large'); break; default: $in->wrapAttr('class', 'uk-width-1-1'); $in->addClass('uk-width-1-1'); break; } } });
-
Anyone knows how to split the checkbox's input and label in 2 divs with Inputfield Markup to look like in the following screenshot? I'm using UIkit so this can be achieved like below but I can't figured out how to do this with Inputfield Markup. <div class="uk-grid-small" uk-grid> <div class="uk-width-auto"> <input id="checkbox" class="uk-checkbox" type="checkbox"> </div> <div class="uk-width-expand"> <label for="checkbox">Checkbox Label</label> </div> </div>
-
Hello @Mikel I'm testing the module and noticed 2 issues. I'm getting the following Warning x2 times when viewing the User Data Table page: Warning: Attempt to read property "type" on null in C:\laragon\www\mysite\site\modules\ProcessUserDataTable\ProcessUserDataTable.module on line 595 The Settings link on User Data Table page is broken as it has a hardcoded admin page name as "cms".
-
@ryan On ProcessWireUpgradeCheck module I'm getting a 500 Internal Server Error and I can ONLY see the updates for the PW dev and master version. No info about the 3rd-party modules.
-
I'm talking about backend files that getting inserted on frontend. I removed everything (header, footer etc.) from my template and just added only the execution line of LoginRegisterPro: <?php namespace ProcessWire; echo $modules->get('LoginRegisterPro')->execute(); ?> and as you can see from the screenshot below the FrontendForms files I mentioned on the previous post are getting inserted. This happens on every form of LoginRegisterPro (login, register, edit profile, forgot password) which are all exist on the same template and triggered by the above 1 line of code. These files are also inserted on every admin page too. You're right.
-
@Juergen the module's CSS / JS are getting executed on a page where LoginRegisterPro is executed even though I have already removed all CSS / JS from your module and the form used by FrontendForms is on a different page. EDIT: These are the files: site/modules/FrontendForms/backend/frontendforms.css?v=2.2.32-1745913193&time=1745913193 site/modules/FrontendForms/image-picker/image-picker.css?v=2.2.32-1745913193 site/modules/FrontendForms/backend/frontendforms.js?v=2.2.32-1745912921&time=1745912921 site/modules/FrontendForms/image-picker/image-picker.min.js?v=2.2.32-174591292
-
Module: Video embed for YouTube/Vimeo (TextformatterVideoEmbed)
PWaddict replied to ryan's topic in Modules/Plugins
@ryan will you consider to add an option to populate the loading="lazy" attribute to iframe tags? Although with a simple hook like below we can get the job done but it would be great if we can have it available on the module. $wire->addHookAfter('Page::render', function(HookEvent $event) { if ($this->wire('page')->template->name != "my-content") return; $event->return = str_replace("<iframe ", "<iframe loading='lazy' ", $event->return); }); -
Module: Video embed for YouTube/Vimeo (TextformatterVideoEmbed)
PWaddict replied to ryan's topic in Modules/Plugins
Adding the native lazy load loading='lazy' on the 381 line of TextformatterVideoEmbed.module doesn't seem to lazy load the iframe. I can see the attribute on the page's code that is injected but all the YouTube scripts are loading on the initial page load even through the embed video is about 2000+ pixels from top. What am I missing??? EDIT: All the Chromium browsers have a very large threshold. On Mozilla the threshold is much lower and the iframe gets loaded when you're getting close to it at about 500px. -
Hi @Juergen, I have 2 quick questions (I haven't installed the module yet). Is the module stable or beta? On the module page info it says "v1.3.7 Stable" but on the description says "This module is early Beta stage - so be aware of using it on live sites!" If I create users programmatically with the proper role will those accounts require verification / activation links to function normally?
-
I'm currently having this issue and fixed it with this hook: /** * CSS: Hide the empty height space of inputfield columns when they stacked (mobile / tablet) on ProcessPageEdit * */ $wire->addHookAfter('ProcessPageEdit::execute', function(HookEvent $event) { $event->return .= " <style> @media only screen and (max-width: 767px) { .maxColHeightSpacer { display: none; } } </style>"; }); EDIT: It seems my hook breaks the image uploading. I read somewhere to enable the UIkit uk-width classes on AdminThemeUikit module and that is actually working.