Skip to main content
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' => $...
Steven Grant's user avatar
  • 1,855
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....
Jake Dohm's user avatar
  • 766
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....
Harald Atteneder's user avatar
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'...
Simon East's user avatar
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.
Eric Anderson's user avatar
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....
cherrykoda's user avatar
  • 1,114
3 votes
Accepted

Test for entry status

status('disabled') should do the trick for you đź‘Ś {% set entries = craft.entries() .section('profileEntry') .status('disabled') .all() %}
Jalen Davenport's user avatar
  • 3,045
3 votes

Change default status of entry publication (Lightswitch 'Status')

As of Craft 2.6.2771, sections now have a “Default Entry Status” section.
Brandon Kelly's user avatar
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 ...
Luke Pearce's user avatar
  • 3,863
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 ...
Robin Schambach's user avatar
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: ...
Jeff Irwin's user avatar
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 ...
Brad Bell's user avatar
  • 67.6k
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 ...
August Miller's user avatar
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 ...
Robin Schambach's user avatar
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() %} {%- ...
carlcs's user avatar
  • 36.3k
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....
James Smith's user avatar
  • 5,689
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 ...
James Smith's user avatar
  • 5,689
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 ...
Josh Parylak's user avatar
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 ...
James White's user avatar
  • 1,191
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 ...
Ben Croker's user avatar
  • 7,796
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', {...
Oli's user avatar
  • 7,515
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 ...
RitterKnight's user avatar
  • 6,582
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 ...
zizther's user avatar
  • 449
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 ...
Oliver Stark's user avatar
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" ...
Damon's user avatar
  • 4,716
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 ...
Paul's user avatar
  • 6,348
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 ...
Robin Schambach's user avatar
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 ...
Luke Holder's user avatar
  • 6,897
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.
Kaushal's user avatar
  • 11
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() %}
SoHo's user avatar
  • 403

Only top scored, non community-wiki answers of a minimum length are eligible