2022 Developer Survey is open! Take survey.

Questions tagged [plugin-development]

Questions having to do with constructing plugins.

Filter by
Sorted by
Tagged with
0 votes
1 answer
12 views

Getting column not found when using 'Entry::find()' to find the matching channel entry in custom plugin

We are building a plugin to perform some custom operations with an ERP system. We created a section for managing the users from ERP. We are able to create new users as channel entries and update them ...
7 votes
3 answers
2k views

Getting all content, including Matrix fields from an EntryModel

Initially I was doing $entry->getContent()->getAttributes(), but noticed my Matrix fields were all null. What is the right way to do this? I see that $entry->myMatrixField gives me the ...
0 votes
0 answers
11 views

DB Query from specific section

I have a website running on craft 2 and I am having trouble with creating queries in a custom plugin controller. I have a section "tasks" and custom field "ordernr". From the ...
4 votes
1 answer
555 views

Craft 3 Custom Plugin: model validation

Struggling a bit here - have created a custom plugin where I want to validate form submission against a predefined model before saving to the database. All pretty straightforward so far … However, if ...
0 votes
0 answers
41 views

What's the correct way to check that an asset file exists?

If I have an asset resource, loaded successfully from the database, whose corresponding file no longer exists on its Volume (irrespective of Volume type), what is the best way to find out if the file ...
1 vote
1 answer
23 views

Feed Me Plugin - Prevent Feed from Being Triggered Multiple Times in Quick Succession

I’d like to prevent a feedme feed from running more than once when multiple requests are received within a few seconds of each other. My first guess is that I would want to target an event such as ‘’’...
0 votes
0 answers
13 views

Can't access Cookie from controller in plugin

In the frontend my website sets a cookie wich i need during a controller action. When calling the controller action from my plugin this Cookie gets duplicated and the value is replaced with an ...
1 vote
1 answer
12 views

User profile - if user logs out after saving an Asset - Invalid subpath “profile/{{currentUser.id}}” - SSO Login fails

Having tested this error only occurs while using the SAML Service provider plugin: I have tested in multiple versioning env and experienced the same issue. I can save an asset file Image or doc while ...
0 votes
0 answers
11 views

Can't change author and dateCreated/postDate on duplicate entry action in Control Panel

We have a Craft-based email campaign builder that is up to date with Craft 3.7.x and plugins. I have a business logic plugin that works for a lot of custom functions but I can't seem to get this going....
1 vote
1 answer
24 views

Is there a way to trigger a user account creation from a different CMS?

I'm a junior web developer working with Craft CMS. I was wondering if there was a way to trigger a controller I have for my Craft CMS from an outside CMS. We have more than one website that offers ...
1 vote
1 answer
832 views

Use default Craft error/exception layout in Plugin

Is it possible for me to use the default Craft error-handling/exception-throwing/debug-showing template layout for my own plugin? Let's say something goes wrong and I want to show that to the user in ...
1 vote
1 answer
110 views

Updating private repo plugins from admin?

Is it possible to update private repo plugins from the admin at all? Would love that functionality, especially for smaller projects that are installed where there's no CLI access.
1 vote
1 answer
28 views

Custom plugin - show popup before element save

I've got a plugin that's got element types. I've got a Transaction element that I need the user to confirm before saving. I've tried to use the jQuery that comes with craft: $('form').submit(function(...
0 votes
0 answers
26 views

Craft Commerce attributes

I was looking for the way to make something like this with Commerce variants: and the only solution that I found is this tutorial: https://www.vaersaagod.no/en/multi-attribute-variant-selection-in-...
1 vote
1 answer
80 views

How to auto enable a plugin after install?

I am developing a plugin for craft 3 and the plugin just got published to the store. I can browse through the store and install the plugin but it stays disabled. The user will have to goto Settings -&...
2 votes
1 answer
49 views

Removing or hiding certain fields from the CP new entry for a specific user group

I'm trying to make some fields unavailable for a certain user group when they create or edit a new entry. These fields should only be available to admin users. I had implemented this by extending the ...
0 votes
0 answers
20 views

Error - Job must be a JobInterface instance instead of __PHP_Incomplete_Class

When I try to run a custom queue job on craftcms, it fails every time and I got this error Job must be a JobInterface instance instead of __PHP_Incomplete_Class, I'm pretty new to craftcms and even ...
1 vote
1 answer
128 views

Posting data from CP to Plugin controller results in server error 500

I am currently trying to write my 1st Craft plugin. The goal (simplified): Backend users select a bunch of pages in the CP, and create a PDF. The result is an annual report that's optimized for print (...
1 vote
1 answer
16 views

Get field settings of custom field via ElementInterface

It is possible to get the field settings via ElementInterface in normalizeValue Method ? I need these settings of my custom field from my plugin : how i can get now these values inside normalizeValue ...
0 votes
0 answers
27 views

How to save the selected assets in custom module

I am trying to create a custom module where I have created an asset uploader field. Images are getting uploaded with that field but not saved. class Settings extends Model { // Public Properties ...
0 votes
0 answers
23 views

Craft 2 Manually Rendered Template - Logic

I'm currently working on a plugin in Craft 2 that will load entries into Ajax and then output to a template, one entry at a time, controlled perhaps by javascript window.setTimeout to advance to the ...
1 vote
1 answer
269 views

Headless Craft CSRF

I have a site that is using Craft CMS headless and React. There are a few forms that need to post to controllers but I'm not sure how to set up the CSRF tokens and keep it secure. Can anyone advise ...
0 votes
0 answers
26 views

What's the recommended approach for applying effects on images and saving them in the respective volumes?

I'm creating a plugin in Craft CMS and it has a feature where you can apply certain image effects and after you are done, you can save it in the configured Asset volume. I know that ImagerX also does ...
-1 votes
1 answer
76 views

how to create a custom plugin if the user enables plugin settings then it will replace the website home page to my custom design? [duplicate]

I am trying to create a plugin if the user enables plugin settings then it will replace the homepage of the website with my custom designed template
1 vote
1 answer
40 views

Event triggered when Craft sends email

Is there an event that would be triggered every time email is being sent by Craft? So email message can be intercepted.
0 votes
1 answer
73 views

How to override homepage content through plugin?

Want to override index.twig content through a custom plugin. I want to create a plugin that appends some content on website homepage. How to Achieve this any reference will be helpful
1 vote
1 answer
16 views

Make plugin permission appear on permission list, without defining control panel section

How can i make plugin permission appear on permissions list, without setting public $hasCpSection = true; in main plugin class? For now i set this variable to true and then removed section link like ...
0 votes
1 answer
88 views

Want to use assets field my template settings in custom plugin craftcms

I am creating a plugin that is based on images the admin will upload some sort of images in plugin settings not sure how to creat image field setting in plugin
1 vote
1 answer
20 views

Plugin logging not appearing

I am trying to log sone info on my plugins service work like below: Craft::info( Craft::t('mapitapi', 'Sleeping for 1 secs ..saved funding entry: ' . $element->id . ':' . $element->...
2 votes
2 answers
506 views

How to reference Twig form values from within controller action?

I have a form and a hidden action that successfully runs the controller action. I now want to include 2 variables (form input values) and then use those values while I am in the controller action. ...
1 vote
1 answer
63 views

How to batch a large queue job?

I am trying to batch a large queue job in my custom plugin. Here is my service that starts the queue. public function doBackGroundJob() { $query = Entry::find(); if (!empty($...
0 votes
0 answers
32 views

Why is my queue in custom plugin failing on VPS but not locally?

I am working on a background job in a custom plugin. On my local Laravel Valet setup it runs fine until it runs out of time. On my VPS which has same php version and memory settings (and mysql db) the ...
1 vote
1 answer
35 views

Index table not displayed on new element type

I am writing a data tables plugin and am currently working on the index page in the CP. I've followed the instructions here: index.twig {% extends '_layouts/elementindex' %} {% set title = "...
1 vote
1 answer
28 views

Save metadata on entry without creating a corresponding field

I am trying to add a seeded:true flag to dummy entries seeded during development, so I can automatically weed (delete) them later when I'm ready to save the actual live content. I know I can create a ...
1 vote
1 answer
62 views

How can I see what fields changed on EVENT_BOEFORE_SAVE and or EVENT_AFTER_SAVE

I want to see what data is changing whenever someone is updating an element to act on the difference between the states. In this particular case a User, but more abstractly speaking, an element. In ...
1 vote
1 answer
120 views

upload base64 image -> save in assets -> custom plugin

I started coding a custom plugin, it takes a video file from the asset and showing the file in a video-player (CP). The user is now able to take screenshots of the video (using JS) by clicking a ...
1 vote
1 answer
68 views

Upload asset via API - Asset saved under root folder

I am trying to seed some images to an existing volume programmatically. The code I'm using is taken (almost) verbatim from Craft's AssetsController@actionUpload: $filename = Assets::...
1 vote
1 answer
61 views

Check for existing jobs in queue

Is it possible in code to search for a job/list out all jobs? I have built a plugin that scans an external API and I want to scan on an interval as well as allow the user to fire off a manual scan. I ...
1 vote
1 answer
42 views

Install plugin from another plugin

I'm trying to use Redactor as a dependency for a plugin I'm writing. I need it to be installed before I run my Install.php migration, because in the migration I'm creating a Redactor field. Following ...
0 votes
0 answers
41 views

getDirtyFields returning more results than expected

I have a module that sends an email whenever a specific entry field is updated. Everything is working fine except that the field is being passed to the dirtyFields array even if it has not been ...
0 votes
0 answers
35 views

Send email from two different addresses using SMTP

I have a configured and fully working Craft 2 website that sends emails using the SMTP settings I have set in the admin panel. I am in need to send a specific email in a certain situation from a ...
1 vote
1 answer
18 views

Composer Unexpected end of file on new plugin

I'm making a new Plugin for CraftCMS, it works fine locally but when I call the services class on our staging server it throws a Syntax Error, Unexpected end of file. I've installed them both through ...
1 vote
1 answer
47 views

Manipulating search event

Looking at a means to perform subqueries against certain searches in the back-end of the Craft CMS eg for searches against particular sections within Admin > Entries. Looking into this it seems ...
1 vote
1 answer
27 views

Limit elementSelectField to specific sections

How do I limit this elementSelectField to only allow entries within a certain section? {{ forms.elementSelectField({ label: 'Blog post', name: 'blogpost', elementType: 'craft\\elements\\Entry', ...
1 vote
1 answer
51 views

How do I renew Craft CMS license?

When I go to Updates in my home Dashboard, I see there are "5 updates available!" I click "Go to Updates" and a big orange ribbon pops up that reads: Your license has expired! ...
4 votes
1 answer
393 views

Set execution order of plugins listening to same event

I have 2 separate plugins that listen to same event. Now I want to make sure Plugin B starts its action only after Plugin A has finished its job. Is there a way in Craft CMS to set priority / ...
0 votes
1 answer
33 views

All Plugins Showing "Not Installed" After Promoting Changes From Dev to Stage Environments

We are using the custom exec widget to move the codebase, backend fields, section creations, and images from one environment to another. We have Dev, Stage, and Production environments. After ...
3 votes
3 answers
653 views

Show field handles on control panel

As someone relatively new to Craft I'm constantly switching between a content type and /admin/settings/fields so that I can see the handles for that content type. It just occurred to me that it would ...
0 votes
0 answers
36 views

How can we create the Martix type field?

In Plugin development, I have created a field, Is it possible to create a field as a matrix field or I will have to create custom add more functionality?
1 vote
1 answer
66 views

How to display controller response on twig template?

In the plugin, I created a form and after the process, return the below response from the controller and redirect to the template. I am trying to print the response to the template but it's not ...

1
2 3 4 5
35