Gravity Forms (WordPress-plugin)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

Sinds 2020 is Gravity Forms m'n standaard formulieren-plugin, op advies van een specialist. Ik denk dat ik 'm ok vind. De belangrijkste dingen gaan heel soepel. Waarschijnlijk zijn het de nag-screens om maar de betaalde versie te kopen, waar ik het meeste moeite mee heb. En dat het de complete backend-interface van WordPress overneemt. Verder is-ie prima.

Installatie WP-CLI-add-on

Standaard ondersteunt Gravity Forms niet de WordPress Command Line Interface. Daar bestaat een gratis add-on voor. Die moet je apart installeren:

wp plugin install gravityformscli --activate

Installing Gravity Forms CLI Add-On (1.4)
Downloading installation package from https://downloads.wordpress.org/plugin/gravityformscli.1.4.zip...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Activating 'gravityformscli'...
Plugin 'gravityformscli' activated.
Success: Installed 1 of 1 plugins.

Activeren:

wp plugin install gravityformscli --activate

wp gf

$ wp help gf

NAME

  wp gf

DESCRIPTION

  Manage Gravity Forms.

SYNOPSIS

  wp gf <command>

SUBCOMMANDS

  check_update      Checks for available updates for Gravity Forms or a Gravity Forms official add-on.
  entry             Manage Gravity Forms Entries.
  field             Manage Gravity Forms Form Fields.
  form              Manage Gravity Forms.
  install           Installs Gravity Forms or a Gravity Forms official add-on.
  license           Manage the Gravity Forms License Key.
  notification      Manage Gravity Forms Notifications.
  setup             Runs the setup for Gravity Forms or a Gravity Forms official add-on.
  tool              Misc Gravity Forms Tools.
  update            Updates Gravity Forms or a Gravity Forms official add-on.
  version           Returns the version of Gravity Forms.

wp gf check_update

wp gf entry

$ wp help gf entry

NAME

  wp gf entry

DESCRIPTION

  Manage Gravity Forms Entries.

SYNOPSIS

  wp gf entry <command>

SUBCOMMANDS

  create            Creates a new entry from either a JSON string with the raw entry or from field-value pairs.
  delete            Deletes an entry.
  duplicate         Duplicates an entry
  edit              Launch system editor to edit the JSON representation of the Entry.
  export            Exports entries.
  get               Returns a JSON representation of an entry.
  import            Imports entries.
  list              Displays a list of entries.
  notification      Send Gravity Forms Notifications.
  update            Updates an entry.

wp gf entry delete

$ wp help gf entry delete

NAME

  wp gf entry delete

DESCRIPTION

  Deletes an entry.

SYNOPSIS

  wp gf entry delete <entry-id>... [--force]

Met de Boolean optie --force worden entries direct verwijderd, ipv. verplaatst te worden naar de prullenbak.

Voorbeelden:

# Delete a form entry
########################################
#
# Delete - Don't move it to trash
#
wp gf entry list 1 --format="ids"

1921 1920 1918 1909 1903 1898 1897 1896 1893 1889 1885 1884 1883 1882 1877 1876 1875 1867 1866 1863^C

$ wp gf entry delete --force 1921

Success: Deleted entry 1921


# Trying out wildcard * to delete all
########################################
#
# Some unexpected behaviour:
#
wp gf entry delete *


Error: Entry with id dvb not found
Error: Entry with id favicon.ico not found
Error: Entry with id help.txt not found
Error: Entry with id index.php not found
Error: Entry with id license.txt not found
Error: Entry with id list.txt not found
Error: Entry with id login.txt not found
Error: Entry with id malcare-waf.php not found
Error: Entry with id order-ids.txt not found
Error: Entry with id order_list.txt not found
Error: Entry with id readme.html not found
Error: Entry with id robots.txt not found
Error: Entry with id text2.txt not found
Error: Entry with id text.txt not found
Error: Entry with id wp not found
Error: Entry with id wp-activate.php not found
Error: Entry with id wp-admin not found
Error: Entry with id wp-blog-header.php not found
Error: Entry with id wp-comments-post.php not found
Error: Entry with id wp-config.php not found
Error: Entry with id wp-config-sample.php not found
Error: Entry with id wp-content not found
Error: Entry with id wp-cron.php not found
Error: Entry with id wp-includes not found
Error: Entry with id wp-links-opml.php not found
Error: Entry with id wp-load.php not found
Error: Entry with id wp-login.php not found
Error: Entry with id wp-mail.php not found
Error: Entry with id wp-salt.php not found
Error: Entry with id wp-settings.php not found
Error: Entry with id wp-signup.php not found
Error: Entry with id wp-trackback.php not found
Error: Entry with id xargs not found
Error: Entry with id xmlrpc.php not found


# "--all" to delete all? Nope
########################################
#
wp gf entry delete --all

usage: wp gf entry delete <entry-id>... [--force]


# No argument to delete all? Nope
########################################
#
wp gf entry delete

usage: wp gf entry delete <entry-id>... [--force]


# Delete all entries form 1-3
########################################
#
wp gf entry delete --force $(wp gf entry list 1 --format="ids" --page_size=100000)
wp gf entry delete --force $(wp gf entry list 2 --format="ids" --page_size=100000)
wp gf entry delete --force $(wp gf entry list 3 --format="ids" --page_size=100000)

wp gf entry list

$ wp help gf entry list

NAME

  wp gf entry list

DESCRIPTION

  Displays a list of entries.

SYNOPSIS

  wp gf entry list <form-id> [--status=<status>] [--format=<format>] [--page_size=<page_size>] [--offset=<offset>]

--format

Mogelijke waardes:

  • table
  • csv
  • json
  • count
  • ids - Deze optie vind je niet snel terug in de documentatie.

-page_size

Standaard worden er 20 entries weergegeven. Met de parameter --page_size kun je dit aanpassen. Ik heb dit getest op formulieren met bijna 900 entries, en dat ging prima. Er lijkt vooralsnog geen bovengrens te zijn.

Voorbeelden:

# Returns number of entries for form 1
########################################
#
wp gf entry list 1 --format="count"


# Return first 20 entry id's form 1
########################################
#
# The option --format="ids" is hardly mentioned on their help page https://docs.gravityforms.com/managing-entries
# and completely not on the inline help, eventhough it's crucial for me to automatically delete entries
#
wp gf entry list 1 --format="ids"


# Return all entry id's form 1
########################################
#
wp gf entry list 1 --format="ids" --page_size=100000

wp gf field

wp gf form

$ wp help gf form

NAME

  wp gf form

DESCRIPTION

  Manage Gravity Forms.

SYNOPSIS

  wp gf form <command>

SUBCOMMANDS

  create            Creates a new form.
  delete            Deletes a form.
  duplicate         Duplicates a form.
  edit              Launch system editor to edit the Form configuration.
  export            Exports forms to a Gravity Forms Form export file.
  field             Manage Gravity Forms Form Fields.
  form_list         Lists the forms with entry count and view counts.
  get               Returns the form JSON.
  import            Imports forms from a Gravity Forms Form export file.
  notification      Manage Gravity Forms Notifications.
  update            Updates a form.

wp gf form create

wp gf form delete

wp gf form edit

De helptekst is niet behulpzaam. Dit is de syntaxis:

wp gf form edit <form-id>

Vervolgens start een editor om een JSON-representatie van het formulier te bewerken.

wp gf form export

wp gf form field

wp gf form form_list

$ wp help gf form form_list

NAME

  wp gf form form_list

DESCRIPTION

  Lists the forms with entry count and view counts.

SYNOPSIS

  wp gf form form_list [--active] [--trash] [--sort_column=<sort_column>] [--sort_dir=<sort_dir>] [--format=<format>]

ALIAS

  list

wp gf form get

wp gf form list

Dit is een alias voor wp gf form form_list. Ik vind deze naam veel logischer dan form_list

wp gf form import

wp gf form notification

wp gf form update

wp gf install

wp gf license

wp gf notification

wp gf setup

wp gf tool

wp gf update

wp gf version

Zie ook

Bronnen