Questions tagged [plugin-development]

Questions having to do with constructing plugins.

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

how to create Super Table field programmatically

i am trying to create a super table field programmatically. this is the code i tried. i see super table field in field list but i can see fields inside of super table. how can i do this? //...
0
votes
0answers
6 views

Handling multi language registration

What would be the proper way to handle the login/registration page in a multi-language site? I can do this: 'loginPath' => [ 'spanish' => 'iniciar-sesion', 'english' => '...
0
votes
0answers
9 views

How to overwrite base controller beforeAction method

How do you override the beforeAction method of Craft's base controller? I'm disabling CSRF for a specific route. public function beforeAction($action): bool { $requestOrigin = \Craft::$app->...
1
vote
1answer
13 views

Assign a category group to a category field via migration

I am writing a plugin that sets up Craft in a particular way and have created a category field, but can't figure out how to assign a category group to the field, I have the following: protected ...
0
votes
0answers
16 views

Is there a way to add a column to entries without making a field?

I would like to add a setting to password protect certain entries if the user chooses. I don't want to create a custom field, but rather have this on the sidebar that the user can toggle on and off ...
1
vote
1answer
23 views

Get all elements (entries) where a field exists

I'm developing a plugin and I'm searching a way to get all entries where a field exists (by id or handle). I'm trying to get all the entries even if the value of the field is null, empty or text. I ...
0
votes
0answers
26 views

Load Entries after click (AJAX)

I try to load a entry after a button is clicked, currently my code looks like this: This is generating a 404 error. Dunno why? <?php /** * PopUp plugin for Craft CMS 3.x * * test * * @link ...
1
vote
1answer
16 views

How to work getFieldValue for assets

I have been implementing my own PHP plugin code. In that, I need to get an asset field in user info. If I can get if the asset is set on the field or not, it is enough. I can get the values of text ...
0
votes
0answers
17 views

Passing variables to email template not working

I am building a Craft plugin which sends emails to users of a subscribed list. I'm trying to get Craft to send the email with a Twig template and pass in variables to that template. So far I've been ...
1
vote
1answer
25 views

Do something on save of an entry

if that entry is in a particular section, then I want to do some task. I can't really find the event docs I need to do that. Everything I've come across has been for Craft 2. Any steps for a hint?
0
votes
0answers
4 views

How Might A HUD Editor Be Extended For A Third Party Field Type?

How might one go about extending a field layout in the Craft CMS control panel HUD editor? Specifically, a Solspace Freeform Submissions field type. Please see attached. We'd like to quick-edit ...
0
votes
0answers
22 views

How can I get uploaded images from my controller and upload them to Craft?

I'm using dropzone to upload images on my front-end. The form action url is to my controller from a custom plugin and that works fine. However, now I'm trying to get the files from dropzone (a json ...
1
vote
1answer
30 views

CSRF in plugin dashboard widget 400 error

Yes, it's another csrf question, the standard, 400 Error - Bad Request: Unable to verify your data submission. If in config/general.php I set 'enableCsrfProtection' => false, then everything works ...
1
vote
2answers
46 views

Parse variables into twig email template from custom module

I'm trying to send an email from my module and am trying to pass some vars into my module template that I can render using twig. Please note that this is a module template not a front end template. $...
1
vote
3answers
30 views

How to create a new Entry model in Craft 3?

I want to create a new entry for a section named 'drinks'(having section id= 6). The namespace of the file having this code is namespace putyourlightson\userguide\controllers;.I copied this code from ...
0
votes
0answers
29 views

Read File from Main Plugin Page

I'm new to plugin creation for Craft 3 and currently stuck trying to read the contents of a JSON file. I can manage it fine from the Settings page using: protected function settingsHtml(): string ...
0
votes
0answers
29 views

Remove an entry's parent via a Craft Plugin or Module

I'm trying to remove/unset the parent from a module, according to the docs it seems like this method should do it: https://docs.craftcms.com/api/v3/craft-base-element.html#method-setparent. However, ...
0
votes
0answers
14 views

Paypal Express, Commerce 3.0, more information on Paypal Invoice

Using Craft 3.4.9 and Commerce Pro 3.0.11 What's the best way to get more information onto a Paypal invoice so that I can match Paypal data with a Craft Commerce order? Does anyone have some success ...
1
vote
1answer
17 views

Not triggering SEOMatic on save element

I'm writing a module that loops over lines in a CSV file to save them as entries. For every entry I save with elements->saveElement($element);, SEOMatic will queue a job that regenerates the ...
1
vote
1answer
23 views

Add new error to macro errorList - User Registration

Using CraftCMS example registration form in the docs. How would I add a new error message to the macro errorList in the registration form: {% macro errorList(errors) %} {% if errors %} ...
0
votes
0answers
11 views

How do I allow partial payments?

The closest thing I found to what I need is here, the problem is, even though it's only 8 months old, it appears outdated. I see there is an "outstanding balance" in the PayController, but I have no ...
0
votes
0answers
36 views

How to move a plugin from dev to prod?

I have a plugin that I developed in a symlinked folder locally. I now want to deploy it to production. But when I do composer require namespace/pluginhandle it gets symlinked. What I want is to ...
0
votes
0answers
26 views

Update category selection in user custom fields

I have a Category "Colors". This category has: Blue, Red, Green I've added a custom users field (CP > Settings > Users > Fields), this field is the category type. "Colors". In the front of website I ...
1
vote
1answer
56 views

PHP warning with composer on MacOS Mojave: Failed to open stream: No such file or directory

I am working on a plugin in Craft:3.4. I get this error while trying to install the plugin in the CP. yii\base\ErrorException: include(/app/vendor/composer/../wittsstratts/craft-company/src/Company....
0
votes
0answers
17 views

Extending Craft controller classes and using private methods in child class

I created Controller that exptends Craft AssetsController. Hovewer some of AssetsController methods are private - and I cannot use them using $this context in child module, so i just copied them to ...
1
vote
1answer
23 views

Sending an e-mail to current user in FeedMe hook

I have made a custom module that allows a user to upload a CSV and import it using a FeedMe feed. This all works fine, however I want to send an e-mail to the user when the import has completed. I ...
1
vote
1answer
15 views

How do I store and retrieve elements for ElementSelectField? Getting error “Call to a member function getUiLabel() on array”

I have a field that allows a user to select multiple products and save them to the database for a plugin, but when I try to retrieve these values and have them selected in my form I get the error ...
1
vote
1answer
25 views

Cannot call service: “'MyPlugin' not found” error

I'm sure this is a trivial mistake but I can't figure it out (first-time plugin dev). I have my plugin running with all code in the controller and want now follow best practice and move the workhorse ...
1
vote
0answers
34 views

How to save dynamically created checkbox values in plugin settings?

I am in the early stages of developing a plugin for Craft 3. In its settings it should have a checkbox for each section the user has defined that enables the admin to select or unselect each section ...
1
vote
1answer
9 views

Getting adjustment amount in a plugin

I need to get the amount of a discount from orders to write that data into a json file (on EVENT_AFTER_COMPLETE_ORDER) which then will be consumed by an inventory management system and now am stuck ...
0
votes
0answers
47 views

Editing a users custom fields from a plugin action Craft 3

Does anyone know if there is a block on updating users form an action? Trying to update a users custom field in craft 3 via plugin in the admin. The admin template calls an ajax call to the action ...
1
vote
1answer
40 views

RegisterUrlRulesEvent rule to display site page

Within a plugin I have written I would like to route POST requests to the plugin controller and GET requests to a single entity created in craft. When the user POSTs to http://example.com/start-your-...
0
votes
0answers
26 views

After calling the controller method error from template. Craft CMS 3

https://prnt.sc/qqs50o I use the base plugin template from plugin factory.
2
votes
1answer
53 views

How can I write a PHP script to zip and download an Assets subfolder?

I've searched everywhere but can't seem to get a straight answer. I want to write a php script to zip and download an entire subfolder in my assets directory. The subfolders are named based on a ...
1
vote
1answer
29 views

How can I access the Gateways services?

I have been trying to access craft\commerce\services\Gateways; from a plugin but I can't figure out how I need to access it. I've used the following: $gateways = Commerce::getInstance()->commerce-&...
1
vote
1answer
17 views

Updating global set from controller

This is my code: $giveaway = Craft::$app->globals->getSetByHandle('promotions'); $giveaway->giveawayName = "New Name"; $success = Craft::$app->globals->saveSet($giveaway); return($...
1
vote
1answer
31 views

\ns\prefix\Plugin::getInstance() returns null from another plugin in Craft 3

I'm building a plugin that extends the functionality of the Contact Form Tuner plugin and customize the email recipients based on different scenarios. The email addresses need to be managed in the ...
1
vote
1answer
69 views

Choose not to save an element on EVENT_BEFORE_SAVE_ELEMENT

I want to do some server side checks to see if the entry should be saved or not. In my plugin I have something like that Event::on( Elements::class, Elements::EVENT_BEFORE_SAVE_ELEMENT, ...
0
votes
0answers
22 views

Craft3 DateTime is updating todays date on element save

I have an issue where my new element is saving with the current date and time. I won't want it to save with any kind of date/timestamp. Does craft just automatically put in the current date and time ...
1
vote
1answer
15 views

Craft 3 replacement for the Craft 2 fileCache component?

I'm upgrading a plugin from Craft 2 to Craft 3 and it looks like the fileCache component is no more. What has replaced it in Craft 3?
1
vote
1answer
63 views

Use sidebar nav icons in modules and plugins

When adding a navigation item, there is the option to specify an icon, but it seems to have to be a path to an SVG. I can see that Craft has its own icon library, and it has an icon I want to use. I ...
0
votes
0answers
22 views

ElementAPI: How to trigger the Custom service php file when a endpoint is loaded

I am Using Craft 3.3.11 version I have a php file in plugin/elementapi/src/services/EapiServices.php and the same file within vendor/craftcms/element-api/src/services/EapiServices.php When ...
0
votes
0answers
29 views

Save and log in a user from event callback

I'm trying to build a plugin wherein after a user is created via the normal means via a front end template, the user is immediately logged in. My module is watching for the after save event on ...
1
vote
1answer
49 views

Frontend form validation

I need to validate the form submitted at the frontend by applying additional validation rules. For that I have created the plugin that listens to "EVENT_BEFORE_SAVE_ENTRY" event and should validate ...
0
votes
0answers
20 views

Create an entry type on plugin install

When a user installs my plugin, I would like the plugin to create an entry type on install. First of all, is this possible? If so, can someone point me in the direction of where I would find ...
1
vote
1answer
109 views

Craft 3 plugin - how to update entry with field of Entries type

Using PHP, I want to update a field of Entries type of an existing entry. Fields of type Text and Number will update with the following code: $entry = Entry::find()->id($entryId)->one(); $...
0
votes
0answers
20 views

Cannot declare class TwigTransformer, because the name is already in use

Within the source code of my plugin I needed to check if another plugin was installed. To do that, I needed to access plugins class. What is the difference between: class Something{ public ...
1
vote
0answers
41 views

Conditionally attach behaviors to craft\elements\Entry by section

I'm trying to conditionally attach behaviors based on an entries section. The following code works fine, but I'm trying to clarify one bit: To avoid a yii\base\InvalidConfigException on the CP ...
0
votes
0answers
38 views

Contact form plugin ajax submit URL not working

I am using contact form plugin for forms in my craft website. For avoiding page redirection, I followed ajax submit for the form, but it is not redirected to controller code. My form is as below:- ...
1
vote
0answers
27 views

Modify preview targets and save them

I'm using the following Event hook : Event::on(Entry::class, Entry::EVENT_REGISTER_PREVIEW_TARGETS, function ($event) { } The $event variable contains an array with the current $previewTargets as ...

1
2 3 4 5
33