Save ACF relationship (name) value to ACF text field

I try to achieve the following.
I have two post types, “projects” & “kuenstlerinnen” (artists)
Within the post type “projects”, there’s an ACF relationship field setup, connecting these two to together → “project_to_kunstlerin”

The post-type “künstlerinnen” (Artists) contains two ACF text fields:
first-name (“artist_vorname”) & Last- or Group-Name (“artist_nachname”). There is a code snippet running, which saves both fields to the title → “artist_vorname””artist_nachname”

I know would like to have a hidden text field within the projects post type, which is automatically populated with the first value of the “project_to_kunstlerin” field. It should only use the last name field. The reason I try to get this to work, is that I can order by this hidden field, so I get the posts ordered by the last name of the artist.

So far I come up with the following code-snippet:

<?php

//Make special artist field autosave for sorting
function write_artist_name_to_hidden( $post_id ) {
    $post_type = 'projects'; //custom post type for events
  
    //Check if we are saving correct post type
    if( get_post_type( $post_id ) != $post_type)
      return;
  
    //Check it's not an auto save routine
    if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) 
      return;
    
    // get the artist id  of the post. Note this is in a relationship field
    $nameofartist = get_post_field ('project_to_kunstlerin', $post);
    
  
    // update the artist value 
    update_field( 'project_kunstlerin_nach_name_sort', $nameofartist, $post_id );
  }
  add_action('save_post', 'write_artist_name_to_hidden');

In the backend, it now populates the destination ACF field with:

One artist: “(“37″)”
Two artists: (“37″,”38”)

These are the IDs.

How can I get another value there instead of the post id?

In theory, it must be something like:

  1. Check with IDs are in the “project_to_kunstlerin” relationship field.
  2. Take the first ID.
  3. Look up, which value is stored in “artist_nachname” of ID in post type “kuenstlerinnen”

Maybe anybody of you has an idea how to get this to work?
Your help is highly appreciated!

dnd 5e – Can Death Ward save you from death due to damage from falling?

While the other two current answers here are correct, I believe that they do the OP a disservice by stating that the matter is simple and not complicated. At least for me, the timing of Death Ward vs. massive damage introduces a non-intuitive level of complication.

but there may be a complicated timing issue

You specified that you are casting Death Ward on yourself, so the least maximum hp you could have would be as a 7th level cleric; a higher level cleric, or any paladin, would have more hp.

Realistically as a cleric you likely have a +2 hp / level from Con at seventh level, so around 52 hp (more with a higher Con or a racial bonus, fewer with a lower Con).

The average of 20d6 (maximum fall damage from a great height) is 70hp, but within the distribution you could receive more than 104 points of damage. Or, you could start the fall wounded, or with a lower hp maximum than 52. The point is that it is entirely possible for the fall damage to exceed the sum of (your current hp + your maximum hp).

Let’s say you are at 52 hp and you take 70hp of damage from the fall. You can’t be at negative hp, so you would go to zero, but then the death ward is triggered and you go to 1hp instead. Death Ward has saved you! You are conscious, no death saves are needed, end of story. This is the simple case.

But suppose you are at 52hp and the fall damage is 104hp or more. Now, the fall damage would take you to 0hp, but you have to worry about two triggers – both the death ward, and the “massive damage” rule which states

Massive damage can kill you instantly. When damage reduces you to 0 hit points and there is damage remaining, you die if the remaining damage equals or exceeds your hit point maximum.

Since you were at 52 hp when you took 104 hp of damage, you would be at 0hp with 52hp of damage “remaining” – this could trigger instant death by massive damage. The death ward would not protect you from this death, because it only protects from instant deaths that kill you without doing damage:

If the spell is still in effect when the target is subjected to an effect that would kill it instantaneously without dealing damage, that effect is instead negated against the target, and the spell ends.

However, the death ward could protect you by making sure your hp are never at 0, since the trigger for the massive damage – instant death rule is “when damage reduces you to 0hp”.

Thus, the question becomes one of what happens first – when your hit points become 0 from the fall, does the death ward reset them to 1 and thus protect you from death by massive damage before it can trigger, or does the massive damage kill you in a way that the death ward cannot prevent before your hp are reset?

As it turns out, death ward goes first because of the way it is worded. As this answer to this question explains, the order of precedence is such that “would be” effects trigger before “reduces” effects. Death ward specifically says

The first time the target would drop to 0 hit points as a result of taking damage, the target instead drops to 1 hit point, and the spell ends.

while the massive damage rule says

When damage reduces you to 0 hit points and there is damage remaining

Because the death ward triggers first, you are never actually at 0 hp, you become 1hp after the fall but before the massive damage rule can apply. Since you are never at 0hp, massive damage cannot trigger.

As the other answers have said, death ward will protect you – but unlike them, I believe it is in a complicated way that depends on the timing of effects.

views – How to save contextual filters (taxonomy) used with one content type to another?

I’m quite new to Drupal and I’m building a site where the user will be able to filter content using taxonomy (for example location, price range free/cheap/expensive,etc.). I want this filter to be kept between pages, from a global view to a specific content and even for different types of content.

Example : User selects a place, a price range. The view is updated with proposed activities. User opens an activity, the filter stays on top. Users selects “restaurants” (other type of content) and sees a view filtered with the same data.

I understand the best way would be to use contextual filters on taxonomy, but how can you save the filter from one page to the next ?

Many thanks for your help.

magento2.4 – Unable to save qty in magento 2.4.2

I am creating product programmatically. Following is the code

enter code here
 $product = $objectManager->create('MagentoCatalogModelProduct');

 try {
  $product->setName('Test Product');
  $product->setTypeId('simple');
  $product->setAttributeSetId(4);
  $product->setSku('test-SKU');
  $product->setWebsiteIds(array(1));
  $product->setVisibility(4);
  $product->setPrice(array(1));
  $product->setImage('/testimg/test.jpg');
  $product->setSmallImage('/testimg/test.jpg');
  $product->setThumbnail('/testimg/test.jpg');
  $product->setStockData(array(
        'use_config_manage_stock' => 0,
        'manage_stock' => 1,
        'min_sale_qty' => 1,
        'max_sale_qty' => 2,
        'is_in_stock' => 1,
        'qty' => 100
    )
);

$product->save();

I have also used “setQuantityAndStockStatus” but qty is not saved.

8 – User warning: issue after submit or save

User warning: The following theme is missing from the file system: calendar_systems in drupal_get_filename() (line 295 of core/includes/bootstrap.inc).
drupal_get_filename(‘theme’, ‘calendar_systems’) (Line: 314)
drupal_get_path(‘theme’, ‘calendar_systems’) (Line: 437)
DrupalCoreAssetLibraryDiscoveryParser->drupalGetPath(‘theme’, ‘calendar_systems’) (Line: 112)
DrupalCoreAssetLibraryDiscoveryParser->buildByExtension(‘calendar_systems’) (Line: 87)
DrupalCoreAssetLibraryDiscoveryCollector->getLibraryDefinitions(‘calendar_systems’) (Line: 66)
DrupalCoreAssetLibraryDiscoveryCollector->resolveCacheMiss(‘calendar_systems’) (Line: 149)
DrupalCoreCacheCacheCollector->get(‘calendar_systems’) (Line: 44)
DrupalCoreAssetLibraryDiscovery->getLibrariesByExtension(‘calendar_systems’) (Line: 58)
DrupalCoreAssetLibraryDiscovery->getLibraryByName(‘calendar_systems’, ‘picker’) (Line: 54)
DrupalCoreAssetLibraryDependencyResolver->doGetDependencies(Array) (Line: 31)
DrupalCoreAssetLibraryDependencyResolver->getLibrariesWithDependencies(Array) (Line: 104)
DrupalCoreAssetAssetResolver->getLibrariesToLoad(Object) (Line: 116)
DrupalCoreAssetAssetResolver->getCssAssets(Object, ) (Line: 315)
DrupalCoreRenderHtmlResponseAttachmentsProcessor->processAssetLibraries(Object, Array) (Line: 161)
DrupalCoreRenderHtmlResponseAttachmentsProcessor->processAttachments(Object) (Line: 45)
DrupalCoreEventSubscriberHtmlResponseSubscriber->onRespond(Object, ‘kernel.response’, Object)
call_user_func(Array, Object, ‘kernel.response’, Object) (Line: 111)
DrupalComponentEventDispatcherContainerAwareEventDispatcher->dispatch(‘kernel.response’, Object) (Line: 191)
SymfonyComponentHttpKernelHttpKernel->filterResponse(Object, Object, 1) (Line: 173)
SymfonyComponentHttpKernelHttpKernel->handleRaw(Object, 1) (Line: 68)
SymfonyComponentHttpKernelHttpKernel->handle(Object, 1, 1) (Line: 57)
DrupalCoreStackMiddlewareSession->handle(Object, 1, 1) (Line: 47)
DrupalCoreStackMiddlewareKernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupalpage_cacheStackMiddlewarePageCache->pass(Object, 1, 1) (Line: 85)
Drupalpage_cacheStackMiddlewarePageCache->handle(Object, 1, 1) (Line: 47)
DrupalCoreStackMiddlewareReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
DrupalCoreStackMiddlewareNegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
StackStackedHttpKernel->handle(Object, 1, 1) (Line: 708)
DrupalCoreDrupalKernel->handle(Object) (Line: 19)

dnd 5e – Is a forced Concentration save a spell effect of a damage-dealing spell?

In our last session the party was ambushed by kobolds, and I included a trio of kobold scale sorcerers, a monster I have not used before.

The scale sorcerers have the ability Heightened Spell, which is nearly identical to the Sorcerer PC metamagic ability:

When it casts a spell that forces a creature to make a saving throw to resist the spell’s effects, the kobold can spend 3 sorcery points to give one target of the spell disadvantage on its first saving throw against the spell.

However, looking at the scale sorcerer’s spell list, of eight spells known, there are only two that would force a saving throw against the spell: poison spray and charm person, but either of them is unlikely to be used during a combat with PCs. Further, the scale sorcerer has only 3 sorcery points, and it would need to use all of them on a heightened spell, so the particular single-use should be one of consequence; far more so then disadvantage on the save against a single use of the poison spray cantrip from a sorcerer that for some reason has entered melee range. Forcing disadvantage on a charm person save would be a great use of heightened spell if cast as part of a social interaction instead of a fight or even after a fight (when the captured sorcerer is negotiating to be spared or released), but again the sorcerer is unlikely to try charm during a fight.

On the other hand, the scale sorcerer has three spells that require attack rolls and do damage: firebolt, chromatic orb, and scorching ray. I believe that tactically, these spells are far more likely to be used in combat against PCs, especially when considering that they synergize with the sorcerer’s Pack Tactics ability. These spells do not force saves directly. However, if cast against a PC caster with a Concentration spell going, their resultant damage would force a Constitution save to maintain concentration, and spending the single-use Heightened Spell ability to give disadvantage on that save (if it was possible) seems like the tactical best-use scenario for the ability.

So, looking again at the Heightened Spell description, would a damage-dealing spell that forces a Constitution save to maintain Concentration be “a spell that forces a creature to make a saving throw to resist the spell’s effects”?

I have checked the 136 instances of “effects” in the PHB and as far as I can tell, there is no game definition of what “spell effects” are, just a lot of contextual references. Thus, “effects” should be interpreted with its ‘natural English’ meaning of “consequences”.

A restrictive approach might be to say that “spell effects” are limited to those specifically listed in the spell description itself; damage is a spell effect, but the Constitution save is an effect of the damage, not an effect of the spell. Further, the Heightened Spell description says that the disadvantage is “on its first saving throw against the spell” itself, not against the spell’s effects.

A permissive approach might be to say that “spell effects” include all mechanistic consequences of the spell. The spell creates damage and the damage forces a save without any choice or “may” conditions intervening, so the Constitution concentration save is an effect of the damage-dealing spell. Further, had the Heightened Spell description been written to specifically exclude such consequences, it needn’t have included the word ‘effects’ at all, and would just have said

When it casts a spell that forces a creature to make a saving throw, the kobold can spend 3 sorcery points to give one target of the spell disadvantage on its first saving throw against the spell.

So, Can the scale sorcerer use their ability to allow it to force disadvantage on the Concentration that result from damage-dealing spells?

sharepoint enterprise – Save conflict adding a content type to list after added as allowed content type in site level doc set template. What do I need to wait for or refresh?

So I’m trying to create a new content type at the site level, add it as an allowed content type in a custom document set content type, and then add it to all the libraries where the document set is used so that it’s actually there for people to use in the doc sets.

All this in a feature upgrade receiver, so C# / server-side code.

Everything goes pretty smoothly except that I’m getting “Save Conflict” SPException when I try to add the content type to each of the lists. I am used to paying attention to when I call Update() on something and then making sure to get a new reference to it if I plan to update it again to avoid those conflicts, but in this case I don’t call update on the lists, and I’m actually getting the references to the lists after I update the document set template, so I don’t see how they could have gotten stale.

Here’s basically how the code goes (although I omitted a lot of logging and error handling for clarity/brevity – I know that the error happens for each library because I’m catching those, so those exceptions are not interrupting the loop):

// at this point the new content type has been created
// successfully, so i get the _site_ level content types
SPContentType newCType = web.ContentTypes("New CType Name");
SPContentType docSetCType = web.ContentTypes("Document Set Name");

DocumentSetTemplate template = DocumentSetTemplate.GetDocumentSetTemplate(docSetCType);
template.AllowedContentTypes.Add(newCType.Id);

// update with pushdown, because the doc set is used in many document libraries
template.Update(true);

// however, that did not actually add the new content type to any libraries,
// it only updated the document set to _allow_ it.  i still need to get the
// new content type into the libraries so users can add them in the doc sets.

// so get the usages
List<SPContentTypeUsage> usages = SPContentTypeUsage.GetUsages(docSetCType).ToList();

foreach (SPContentTypeUsage usage in usages)
{
    if (usage.IsUrlToList)
    {
        // how can this not be a fresh reference to the libraries?
        // i didn't get this reference _before_ i updated the document set template,
        // i'm getting these references _after_ that update.
        SPList list = web.GetList(usage.Url);

        // i double check to make sure it wasn't automatically added when
        // the doc set template was updated, and i know it wasn't because...
        SPContentType listLevelCType = list.ContentTypes(newCType.Name);
        if (listLevelCType == null)
        {
            // ...i have a log entry here to indicate that i am about to try to add it
            listLevelCType = list.ContentTypes.Add(newCType);

            // and this is what causes the save conflict.
        }
    }
}

What am I missing here? What do I need to refresh my reference to in order to not get a save conflict when adding to the lists’ content type collections?

Credit card textfield: Prevent to save in the database

How can I prevent the credit card textfield saves on the database?