6
votes
Accepted
Create a pending user from plugin
Rolling with this does what I need
$newUser = new User([
'firstName' => $submission->firstName->getValue(),
'lastName' => $submission->lastName->getValue(),
'username' => $...
6
votes
Accepted
If page is enabled, show div
You can check the status of an entry with .status. https://craftcms.com/docs/templating/craft.entries#status
This code should work!
{% set jobsEntry = craft.entries.id(jobsId) %}
{% if jobsEntry....
5
votes
Entry next sibling return a deactivated entry
Just an updated version of Marion's answer for Craft CMS 3 since order and first are deprecated.
{% set prev = craft.entries.positionedBefore(entry).orderBy('lft desc').one() %}
{% set next = craft....
4
votes
Editorial workflow / custom status
Douglas has posted a great suggestion about creating an additional custom field for "Status". But I think it's also worth mentioning Josh Crawford's great free plugin called Workflow which takes Craft'...
3
votes
Accepted
How to programatically disable an entry for a specific site
I have had success passing an array of siteId => bool like so $entry->enabledForSite = ['1 => false']; and then saving the element.
3
votes
Accepted
How to disable all entries of certain section types?
If you need to do this on-demand, you could add a console controller to a custom module so that you can run it via command.
This page in the Craft docs explains how to set that up:
https://craftcms....
3
votes
Accepted
Test for entry status
status('disabled') should do the trick for you đź‘Ś
{% set entries = craft.entries()
.section('profileEntry')
.status('disabled')
.all() %}
3
votes
Change default status of entry publication (Lightswitch 'Status')
As of Craft 2.6.2771, sections now have a “Default Entry Status” section.
3
votes
Set status 'pending' on Guest Entry form
The "status" on an entry isn't explicitly set like that. It is determined based on other properties of the entry. You will need to set these other criteria for the entry to appear as "pending".
An ...
3
votes
In Craft 3, (how) can I disable a category on a per site basis?
I guess it is either a bug or the developers don't want us to do it via cp request. In my plugin (phpCode) I can activate and deactivate categories per site easily but the cp template is missing the ...
2
votes
If page is enabled, show div
I ran into the same problem where if a page was 'disabled', I didn't want it to show in my footer navigation. The recommended answer didn't work for me. The link still showed up. The following worked:
...
2
votes
Accepted
Event when an entry is enabled
Well, that's awkward.
The SetStatusEvent was removed way back in the Craft 3.0 launch, but the class itself was never removed (will fix that for the upcoming 3.4 launch).
There isn't really a clean ...
2
votes
Commerce 1: Different default order status based on product types
Edit: I'm sorry! I missed Commerce 1 in the title! This answer only applies to Commerce 2.
Take a look at the defaultOrderStatus event!
The description is a bit misleading—it's actually used to do ...
2
votes
Accepted
Display notification if no entries exist for status criteria and logged in user
Why don't you just grab disabled entries from the author?
{% set entries = craft.entries
.section('profileEntry')
.status('disabled')
.authorId(currentUser.id)
.all() %}
Then you ...
2
votes
Accepted
How can I use the Courier plugin to notify a user when an entry is enabled?
In your Courier Blueprint listen to entry.beforeSaveEntry events and use this code for the Trigger Condition:
{% set oldEntry = craft.entries({
id: entry.id,
status: null,
}).first() %}
{%- ...
2
votes
Craft 3 - Twig search query for entry with custom EntriesField containing disabled entry
The search parameter only searches the element that is the subject of your element query (i.e., the source entry) - it does not search related entries. For that you need to use the relatedTo parameter....
2
votes
Accepted
Craft Commerce — Update order status from frontend?
This feels a bit dirty, but you can actually do this directly in a Twig template like this:
{% set order = craft.orders.id(123).one() %}
{% do order.setAttributes({orderStatusId: 4}, false) %}
{% do ...
2
votes
Accepted
Specific emails failing in queue
I'm going to lay out the answer here, in case someone else runs into someone else's issue. We are using Postmark to process emails.
All of the failures in the queue are email addresses that have ...
1
vote
How to programatically disable an entry for a specific site
I'm not sure setEnabledForSite takes two arguments if you look at the class reference, it seems to only take one.
https://docs.craftcms.com/api/v3/craft-base-element.html#method-setenabledforsite
...
1
vote
How to disable all entries of certain section types?
A content migration is probably the best approach to take. This way, any other modules/plugins that listen to entry events will be able to take the necessary action, and you can run and test it in ...
1
vote
Accepted
Eager load expired entries
Assuming this is an Entries field in a Matrix block, the syntax is:
{% set ideas = craft.entries()
.section('ideas')
.status('live')
.with([
['matrixField.blockType:entriesField', {...
1
vote
Specific emails failing in queue
It sounds like you have either an order issue or a queue issue.
What happens if you try to send that specific email from the order's edit screen?
If it's a Twig/order email / syntax problem, you'll ...
1
vote
Update entry Enabled value based on field value when saving
Looking into this more and understanding how Craft works, a post date needed to be set, it will not do this automatically for you.
On saving the entry, it will check to see if the entry is enabled ...
1
vote
Accepted
live and pending entries together not working
Use status(['live','pending']) to get all entries with both states.
Later, to get the linked entry you need to setup a custom route like `podcasts/{slug}. In the template you query the entry like ...
1
vote
How can I set an entires status via ajax from a front-end form?
Thank you for all of the time spent Paul - I very much appreciate it.
Instead of using ajax, I went with a more "traditional" approach. This is what my template looks like now:
<form method="post" ...
1
vote
How can I set an entires status via ajax from a front-end form?
My best guess, based on what you want to do, is that you don't have the correct permissions to change the entry's status. The requirePermission method kicks in and will send a 403 if you don't have ...
1
vote
Accepted
Get all entries for a structure section including disabled
{% set events = craft.entries.section('events').first() %}
{% for event in events.children().status(null).find() %}
{% for day in event.children().status(null).find() %}
{% for session in ...
1
vote
Accepted
How to save Order Status Message in Craft Commerce using frontend form
Updating an order from the front end would not be possible unless the user has update/manage order permissions.
As for the message it is simply a message post param that you send along with the ...
1
vote
Change default status of entry publication (Lightswitch 'Status')
In the Admin CP navigate to Settings -> Sections and choose the entry type you want to change;
In the Site Settings table, toggle the Default Status lightswitch to off.
1
vote
How do I find live and pending entries when using an array?
For Craft CMS 3:
{% set allEntries = craft.entries.status('pending, live').section('sectionName').relatedTo(category).find() %}
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
status × 40entries × 13
templating × 7
entry × 6
craft3 × 4
pending × 4
plugin-development × 3
users × 3
emails × 3
plugin-craftcommerce × 2
categories × 2
form × 2
events × 2
migration × 2
modules × 2
category × 2
plugin-craftcommerce3 × 2
order × 2
localization × 1
search × 1
php × 1
elementcriteriamodel × 1
admin × 1
multi-site × 1
conditional × 1