EulandaXtools — Funktionsreferenz
Liest einen einzelnen Gravity-Forms-Entry (Bestellung) über WordPress und gibt die Formular-Metadaten sowie die zugehörigen Feldwerte strukturiert zurück.
Get-WordPressGfOrder [-BaseUrl] <string> [-FormId] <int> [-ConsumerKey] <string> [-ConsumerSecret]
<string> [-EntryId] <int> [[-TimeoutSec] <int>] [<CommonParameters>]Diese Funktion ruft über die Gravity Forms REST API v2:
Dabei wird:
Die Authentifizierung erfolgt per HTTP Basic Auth mit ConsumerKey und ConsumerSecret, den Gravity Forms REST API Keys.
Das Ergebnis ist bewusst so aufgebaut, dass es sich gut für:
-BaseUrl
Type: stringBasis-URL der WordPress-Installation, z.B. https://example.com. Ein eventuell vorhandener Slash am Ende wird automatisch entfernt.
-FormId
Type: intDie ID des Gravity-Forms-Formulars, zu dem der Entry gehören muss.
-ConsumerKey
Type: stringGravity Forms REST API Consumer Key.
-ConsumerSecret
Type: stringGravity Forms REST API Consumer Secret.
-EntryId
Type: intDie ID des Gravity-Forms-Entries, wobei ein Eintrag gleich eine Bestellung ist, der geladen werden soll.
-TimeoutSec
Type: int
Default: 60Timeout für die REST-Aufrufe in Sekunden. Standard ist 60, erlaubt sind Werte von 1 bis 300.
[pscustomobject]Das zurückgegebene Objekt hat folgende Struktur: - EntryId : ID des Entries - FormId : Formular-ID - DateCreated : Erstellungsdatum des Entries - Status : Status des Entries (z.B. active) - Meta.Fields : Hashtable mit Feld-Metadaten (FieldId, FieldLabel) - Data : Hashtable mit den tatsächlichen Feldwerten (Key = FieldId)
# Einzelnen Gravity-Forms-Entry laden
$order = Get-WordPressGfOrder `
-BaseUrl 'https://shop.example.de' `
-FormId 1 `
-EntryId 46 `
-ConsumerKey 'ck_xxxxxxxxxxxxxxxxx' `
-ConsumerSecret 'cs_xxxxxxxxxxxxxxxxx'# Zugriff auf ein bestimmtes Feld über die FieldId
$order = Get-WordPressGfOrder `
-BaseUrl 'https://shop.example.de' `
-FormId 1 `
-EntryId 46 `
-ConsumerKey 'ck_xxxxxxxxxxxxxxxxx' `
-ConsumerSecret 'cs_xxxxxxxxxxxxxxxxx'
# Beispiel: Feld 11 (z.B. Name oder E-Mail)
$order.Data['11']# Alle Feld-Labels mit Werten ausgeben
$order = Get-WordPressGfOrder `
-BaseUrl 'https://shop.example.de' `
-FormId 1 `
-EntryId 46 `
-ConsumerKey 'ck_xxxxxxxxxxxxxxxxx' `
-ConsumerSecret 'cs_xxxxxxxxxxxxxxxxx'
foreach ($id in $order.Meta.Fields.Keys) {
[pscustomobject]@{
FieldId = $id
FieldLabel = $order.Meta.Fields[$id].FieldLabel
Value = $order.Data[$id]
}
}