Search if menu item has child in wp_get_nav_menu_items hook

I am conditionally showing menu items. All is fine but want to remove parent item if returning no child items.

For example if I have a parent menu (it will always be a custom link with #) called More and it has multiple child items (mostly one level). Now if I am hiding child items based on user roles and for some roles no child items available, in that case, I want to remove More menu items also since it has no child.

I am trying with the following code but since $item is an object, array_search won’t work. So how can I check for child-parent and remove the menu item if it has no child?

array_search( $item( 'ID' ), array_column( $item, 'menu_item_parent' ) )

Below is the working code that hides menu item based on user roles.

public static function exclude_menu_items( $items, $menu, $args ) {

    if ( current_user_can( 'administrator' ) ) {
        return $items;
    }

    foreach ( $items as $key => $item ) {

        if ( $page = get_post( $item->object_id ) ) {
            if ( $page->post_type == 'page' ) {
                $template  = get_post_meta( $page->ID, '_wp_page_template', TRUE );
                $post_type = self::get_cpt_for_template( $template );

                if ( $post_type && ( ! current_user_can( 'cp_access_' . $post_type ) || ! ( new self() )->is_current_user_granted_for_module( $post_type ) ) ) {
                    unset( $items( $key ) );
                }
            }
        }
    }

    return $items;
}

magento2.3 – Magento 2.3 – Get category of item related foreach

I want to load the category name and category url of the item that is displayed as a related item on the productpage.

So inside the foreach element, I want to load the category name and url of the related item itself.

How can I get the category name of a item in Magento 2.3?

I tried the following that seems to work well, but I do not want to a load a objectManager on frontend, so what is the best way to load this otherwise?

<?php $objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->get('MagentoFrameworkRegistry')->registry('current_product');
$categories = $product->getCategoryIds(); /*will return category ids array*/
foreach($categories as $category){
    $cat = $objectManager->create('MagentoCatalogModelCategory')->load($category);
    echo $cat->getName();
    }

?>

sharepoint online – SPFX open new list item using modal dialog

The code below opens a new item in Iframe/modal dialog. But when the user saves or closes the modal form i would like it to be closed and not redirected to any other page.

Is there any way I can close the modal form when the item is saved.

The option to create a custom form with all the controls seems a bit long winded.

<PrimaryButton text={'Open Dialog'} onClick={this._onClick.bind(this)} />
<PrimaryButton text={'Open Clients Form'} onClick={this._onClientClick.bind(this)} />
<IFrameDialog
  url={'/Lists/MyList/NewForm.aspx'}
  iframeOnLoad={this._onDlgLoaded.bind(this)}
  hidden={!this.state.isDlgOpen}
  onDismiss={this._onDlgDismiss.bind(this)}
  modalProps={{
    isBlocking: true
  }}
  dialogContentProps={{
    type: DialogType.close,
    showCloseButton: true
  }}
  width={'800px'}
  height={'900px'} />

How do i get a handle of the Iframe and check if the src is still pointing to the same url . I can close the modal dialog.

private _closeModal = (): void => {
    this.setState({ showModForm: false });
  } 
  private _onDlgDismiss(): void {
    this.setState({
      isDlgOpen: false
    });
  }

  private _onDlgLoaded(): void {

    console.log('dlg is loaeded');
  }

sharepoint online – When adding an item programmatically the workflow 2013 will raise access denied

I have defined a workflow which gets fired when adding items on listA. and if i directly add an item inside listA using the UI the workflow will work well. but on listB i have a remote event receiver which programmatically create a list item inside listA.

but when the remote event receiver create an item inside listA, the workflow will raise this error:-

Retrying last request. Next attempt scheduled in less than one minute. Details of last request: HTTP Forbidden to https://****/_api/web/lists(guid'd20db253-4447-4133-99b0-757eee9eb37e')/Items(212)?%24select=ID%2CProjectCurrentUpdate Correlation Id: 4590651d-d586-53c6-9ebc-5db114ddcfbe Instance Id: 1cf54ed9-97ee-4de3-b361-edbef338b249 

Access denied. You do not have permission to perform this action or access this resource. 

unity – Change item rotation axis in inventory item visualization

I’m learning unity and i’m trying now make an inventory, i made a simple interface, and now i’m trying to make a item visualization. I look for some codes from web and i found this one:

using UnityEngine;

public class TurnObject : MonoBehaviour
{
    protected Vector3 posLastFame;
    public Camera UICam;

    // Update is called once per frame
    void Update()
    {
        if(Input.GetMouseButtonDown(0)) {
            posLastFame = Input.mousePosition;
        }    

        if (Input.GetMouseButton(0)) {
            var delta = Input.mousePosition - posLastFame;
            posLastFame = Input.mousePosition;

            var axis = Quaternion.AngleAxis(-90f, Vector3.forward) * delta;
            transform.rotation = Quaternion.AngleAxis(delta.magnitude * 0.1f, axis) * transform.rotation;
        }
    }
}

I know some code, but I’m not good with geometrics. In this code when I move my mouse horizontal way, my object turn in the Y axis. And that’s good. But when I move my mouse vertical the object move in the X axis instead of Z axis.

Is there a way in this code for change this? I really have difficulty to understanding geometrics in Unity.

c# – How make a good item visualizer in unity?

I’m learning unity and i’m trying now make an inventory, i made a simple interface, and now i’m trying to make a item visualization. I look for some codes from web and i found this one:

using UnityEngine;

public class TurnObject : MonoBehaviour
{
    protected Vector3 posLastFame;
    public Camera UICam;

    // Update is called once per frame
    void Update()
    {
        if(Input.GetMouseButtonDown(0)) {
            posLastFame = Input.mousePosition;
        }    

        if (Input.GetMouseButton(0)) {
            var delta = Input.mousePosition - posLastFame;
            posLastFame = Input.mousePosition;

            var axis = Quaternion.AngleAxis(-90f, Vector3.forward) * delta;
            transform.rotation = Quaternion.AngleAxis(delta.magnitude * 0.1f, axis) * transform.rotation;
        }
    }
}

I know some code, but I’m not good with geometrics. In this code when I move my mouse horizontal way, my object turn in the Y axis. And that’s good. But when I move my mouse vertical the object move in the X axis instead of Z axis.

Is there a way in this code for change this? I really have difficulty to understanding geometrics in Unity.

sharepoint server – Why are image attachments silently disappearing when trying to add them to list item through our wcf-service?

When using our WCF-service to add an attachment to a list item, files that are named with a image extension (“xxx.jpg”, “xxx.png”, etc) are triggering an discrete error:

w3wp.exe (0x3934)   0x1698  SharePoint Foundation   Unified Logging Service ajsqu   High    mutex creation failed. error code = 1346

Error 1346 is a Windows system error code and means Either a required impersonation level was not provided, or the provided impersonation level is invalid..

When using ProcMon I see som BAD IMPERSONATION for entries for both a request with a text file that works as expected, and for a request with an image that fails. There are slight differences though in the end:

Failed request (with an image extension in the file name)

11:37:55.9475993 AM w3wp.exe    12692   RegOpenKey  HKU.Default    BAD IMPERSONATION   Desired Access: Maximum Allowed
11:37:56.0344555 AM w3wp.exe    12692   RegOpenKey  HKLMSystemCurrentControlSetControlCryptographyProviders    BAD IMPERSONATION   Desired Access: Read
11:37:56.0346125 AM w3wp.exe    12692   RegOpenKey  HKLMSystemCurrentControlSetControlCryptographyProviders    BAD IMPERSONATION   Desired Access: Read
11:37:56.0346808 AM w3wp.exe    12692   RegOpenKey  HKLMSystemCurrentControlSetControlCryptographyProviders    BAD IMPERSONATION   Desired Access: Read
11:37:56.1581212 AM w3wp.exe    12692   RegOpenKey  HKLMSystemCurrentControlSetControlCryptographyProviders    BAD IMPERSONATION   Desired Access: Read
11:37:56.1582325 AM w3wp.exe    12692   RegOpenKey  HKLMSystemCurrentControlSetControlCryptographyProviders    BAD IMPERSONATION   Desired Access: Read
11:37:56.1582954 AM w3wp.exe    12692   RegOpenKey  HKLMSystemCurrentControlSetControlCryptographyProviders    BAD IMPERSONATION   Desired Access: Read
11:37:56.9824610 AM w3wp.exe    12692   RegOpenKey  HKLMSOFTWAREMicrosoftShared ToolsWeb Server Extensions15.0IRMProtectors   BAD IMPERSONATION   Desired Access: Read
11:37:58.0455812 AM w3wp.exe    12692   QueryOpen   C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15BINOISIMG.DLL  BAD IMPERSONATION   
11:37:58.0456718 AM w3wp.exe    12692   QueryOpen   C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15BINOISIMG.DLL  BAD IMPERSONATION   
11:37:58.0457252 AM w3wp.exe    12692   QueryOpen   C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15BINOISIMG.DLL  BAD IMPERSONATION   
11:37:58.0459377 AM w3wp.exe    12692   QueryOpen   C:WindowsSystem32KernelBase.dll  BAD IMPERSONATION   
11:37:58.0462135 AM w3wp.exe    12692   QueryOpen   C:WindowsSystem32dbghelp.dll BAD IMPERSONATION   
11:37:58.0463792 AM w3wp.exe    12692   RegOpenKey  HKLMSystemCurrentControlSetControlSession Manager   BAD IMPERSONATION   Desired Access: Query Value, Enumerate Sub Keys
11:37:58.5275449 AM w3wp.exe    12692   QueryOpen   C:WindowsSystem32 BAD IMPERSONATION   
11:37:58.5276784 AM w3wp.exe    12692   RegOpenKey  HKLMSoftwareMicrosoftWindows NTCurrentVersionAeDebug   BAD IMPERSONATION   Desired Access: Query Value
11:37:58.5281365 AM w3wp.exe    12692   CreateFile  C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Filesrootcffadaffaa3d2820profileoptimization.prof BAD IMPERSONATION   Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, AllocationSize: 0, Impersonating: ADSA00421
11:37:58.5290753 AM w3wp.exe    12692   CreateFile  C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Filesroote7a8199860d7fd38profileoptimization.prof BAD IMPERSONATION   Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, AllocationSize: 0, Impersonating: ADSA00421
11:38:00.2067183 AM w3wp.exe    12692   RegOpenKey  HKLMSoftwarePolicies  BAD IMPERSONATION   Desired Access: Read
11:38:00.2067683 AM w3wp.exe    12692   RegOpenKey  HKLMSoftware   BAD IMPERSONATION   Desired Access: Read
11:38:00.2096010 AM w3wp.exe    12692   RegOpenKey  HKLMSoftwarePolicies  BAD IMPERSONATION   Desired Access: Read
11:38:00.2096538 AM w3wp.exe    12692   RegOpenKey  HKLMSoftware   BAD IMPERSONATION   Desired Access: Read

Successful request (with a text file name)

4:35:41.5836886 PM  w3wp.exe    14500   RegOpenKey  HKU.Default    BAD IMPERSONATION   Desired Access: Maximum Allowed
4:35:41.6093915 PM  w3wp.exe    14500   RegOpenKey  HKLMSoftwareMicrosoftMSSQLServerClientSuperSocketNetLib    BAD IMPERSONATION   Desired Access: Read
4:35:41.6096744 PM  w3wp.exe    14500   RegOpenKey  HKCRCLSID{0A29FF9E-7F9C-4437-8B11-F424491E3931}InprocServer32    BAD IMPERSONATION   Desired Access: Read
4:35:41.6097987 PM  w3wp.exe    14500   RegOpenKey  HKCRCLSID{0A29FF9E-7F9C-4437-8B11-F424491E3931}InprocServer32    BAD IMPERSONATION   Desired Access: Read
4:35:41.6415277 PM  w3wp.exe    14500   RegOpenKey  HKLMSoftwareMicrosoftMSSQLServerClientSuperSocketNetLib    BAD IMPERSONATION   Desired Access: Read
4:35:41.6621615 PM  w3wp.exe    14500   RegOpenKey  HKCRCLSID{BDEADF26-C265-11D0-BCED-00A0C90AB50F}InprocServer32    BAD IMPERSONATION   Desired Access: Read
4:35:42.0190194 PM  w3wp.exe    14500   RegOpenKey  HKCRCLSID{BDEADF26-C265-11D0-BCED-00A0C90AB50F}InprocServer32    BAD IMPERSONATION   Desired Access: Read

Another strange is that this has recently worked without any problems, then stopped working, then started working again just to stop working again over the timespan over some days, and I have no idea of what the variable factor could be.

Something is sometimes triggering on that the file is named as an image file and then runs some other code that crashes due to what seems to be invalid permissions. Other concurrent updates on the list item are fine, it’s just the attachments that disappears. What can this be?

Query for unique item in list

I have an SP list of items, each item has a unique Title. I would like to use the title as my way to find and then update that row of data. I thought the below code would find only the item that has a Title = “Apptest” but it always gives me all items in the list and all of them are updated. I get the same results if I remove the ViewXml line, so I think there is something wrong with that line but I can’t find it. Before:
Before running code After:After running the code

var list = clientContext.Web.Lists.GetByTitle("Test");
            var camlQuery = new CamlQuery
            {
                ViewXml = @"<Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Apptest</Value></Eq></Where></Query>"
            };

            var listItems = list.GetItems(camlQuery);
            clientContext.Load(listItems);
            clientContext.ExecuteQuery();

            foreach (var listItem in listItems)
            {
                Console.WriteLine($"{listItem("Title")}");
                listItem("Title") = "AppUpdateTest";
                listItem.Update();
                clientContext.ExecuteQuery();
            }

dnd 5e – Do class or subclass features that relate to spellcasting apply when producing a spell’s effect from an Artificer’s Spell-Storing Item?

In my recent question about a homebrewed Artificer subclass, I was asked in a comment how one of the abilities that modifies spellcasting would interact with casting spells stored within a my subclass’s variant version of the Spell-Storing Item feature that all Artificers get. I’d not considered it before, but I suspect it should work the same as a normal spell cast from a normal Spell-Storing Item.

But as it turns out, I’m not actually sure how that works for normal Artificers either. The relevant rules text for the Spell-Storing Item feature says (from Eberron: Rising from the Last War, page 58, and the latest version of Wayfinder’s Guide to Eberron, p. 179-180) says:

While holding the object, a creature can take an action to produce the spell’s effect from it, using your spellcasting ability modifier. If the spell requires concentration, the creature must concentrate.

Notable in that rules text is that it does not say that the creature using the object casts the spell, only that it produces the spell’s effect. This seems relevant because the top voted answers to this previous question seem to mostly attach to the “cast” terminology used by most magical items that grant extra spells.

In combination with the answers to that question, it seems like the different language (not using “cast”) may mean that using a Spell-Storing Item isn’t spellcasting, and so no feature that modifies spellcasting will apply. But there’s enough ambiguity that I want to ask about it here.

Do an artificer’s spellcasting-related features apply to spells they store in an item? Do spellcasting-related features of the creature using the Spell-Storing Item (which may or may not be the Artificer themself) apply?

For a concrete example, if an Artillerist stores Scorching Ray in a wand, staff or rod that they had previously made their Arcane Firearm, would they get an get an extra d8 to add to one of the spell’s damage rolls when they use the stored spell?

flow – Capture Version of Document set automatically when an item is changed

Does anyone know if there´s any way I can set up a flow in power automate to capture a version of a document set when an item is changed? (e.g Major Version published)I know there are not out of the box features do deal with docsets in power automate (at least for know), but perhaps with the action “send http request to sharpoint” there’s a way I can do it. If anyone knows a way to do this (even without power automate) I would be extremly glad.

Thanks