### Composer Initialization Answers Example Source: https://gravitywiz.com/documentation/installing-plugins-with-composer An example of how to answer the prompts during `composer init` to generate the `composer.json` file. ```bash Package name (/): ollivanders/magical-wordpress-site Description []: My WordPress Wand Shop Author: [Dave Smiff , n to skip]: n Minimum Stability []: // leave empty if not specified Package Type []: // leave empty if not specified License []: // leave empty if not specified Would you like to define your dependencies (require) interactively [yes]? n Would you like to define your dev dependencies (require-dev) interactively [yes]? n Add PSR-4 autoload mapping? Maps namespace to the entered relative path. [src/, n to skip]: n Do you confirm generation [yes]? yes ``` -------------------------------- ### Example URL Generated by [gpqr] Source: https://gravitywiz.com/documentation/gravity-forms-qr-code This is an example of the URL that would be generated by the [gpqr] shortcode when format="url" is used. ```html http://yoursite.local/wp-content/uploads/gravity_forms/gpqr-codes/25b22f6b66f94db6d1e889b9a85c7fe4.png ``` -------------------------------- ### WP-CLI Command: Seed Database with Example Data Source: https://gravitywiz.com/documentation/gravity-forms-bookings Populate your database with example bookings, services, resources, forms, and entries. Use the --create-pages flag to also create necessary pages. ```bash wp gp-bookings seed --create-pages wp gp-bookings seed --skip-bookings ``` -------------------------------- ### Log booking rescheduling details Source: https://gravitywiz.com/documentation/gpb_rescheduled This example demonstrates how to log the booking ID, new start, and new end times when a booking is rescheduled. It uses an anonymous function to handle the action. ```php add_action('gpb_rescheduled', function($booking, $new_start, $new_end) { error_log("Booking {$booking->get_id()} rescheduled to {$new_start} - {$new_end}"); }, 10, 3); ``` -------------------------------- ### Initialize Composer Project Source: https://gravitywiz.com/documentation/installing-plugins-with-composer Run this command in your site's root folder to start the Composer initialization process. ```bash composer init ``` -------------------------------- ### Set Custom Starting Page via Query String Source: https://gravitywiz.com/documentation/gravity-forms-multi-page-navigation Append '?gpmpn_page=X' to the form's URL to set a custom starting page. This requires the 'page' parameter to be set in the shortcode for security. ```url http://mysite.com/my-form-page/?gpmpn_page=2 ``` -------------------------------- ### Set default values for user-facing filters Source: https://gravitywiz.com/documentation/gpeb_selected_user_filters This example demonstrates how to set default values for user-facing filters within the `gpeb_selected_user_filters` hook. It initializes filters based on predefined defaults or GET parameters. ```php add_filter( 'gpeb_selected_user_filters', function( $filters, $form_id ) { $default_values = array( // Field/Input ID => Default Value 1 => 'Second Choice' ); $filters = array(); foreach ( $default_values as $input_id => $default_value ) { $filters[ $input_id ] = rgars( $_GET, 'filters/' . $input_id, $default_value ); } return $filters; }, 10, 2 ); ``` -------------------------------- ### Restrict Bookings to Start 3 Days From Now Source: https://gravitywiz.com/documentation/gpb_availability_start Prevent same-day or next-day bookings by requiring at least 3 days advance notice. This example sets an absolute minimum date for bookings. ```php add_filter( 'gpb_availability_start', function( $start, $service, $resource_ids ) { return \Carbon\CarbonImmutable::today()->addDays( 3 ); }, 10, 3 ); ``` -------------------------------- ### Install Dependencies from composer.lock Source: https://gravitywiz.com/documentation/installing-plugins-with-composer Recreate the project's dependencies on a new device or after cloning by running this command. ```bash composer install ``` -------------------------------- ### Supported Barcode Type Examples Source: https://gravitywiz.com/documentation/gravity-forms-qr-code Examples demonstrating the output for different supported barcode types using the ':type' modifier. These include PDF417, UPCA, and PHARMA. ```php {My Field:1:qr,type[PDF417]} ``` ```php {My Field:1:qr,type[UPCA]} ``` ```php {My Field:1:qr,type[PHARMA]} ``` -------------------------------- ### Sample composer.json Configuration Source: https://gravitywiz.com/documentation/installing-plugins-with-composer A sample `composer.json` file demonstrating the setup for Gravity Wiz plugins, including required packages and repository configuration. ```json { "name": "ollivanders/magical-wordpress-site", "description": "My WordPress Wand Shop", "require": { "gravitywiz/gwreadonly": "^1.9", "gravitywiz/gp-populate-anything": "^2.1" }, "repositories": { "gravitywiz": { "type": "composer", "url": "https://gravitywiz.com/composer" } }, "config": { "allow-plugins": { "composer/installers": true } } } ``` -------------------------------- ### WP-CLI Command: Get Help for GP Bookings Source: https://gravitywiz.com/documentation/gravity-forms-bookings Displays detailed information about the wp gp-bookings command and its subcommands. ```bash wp gp-bookings --help ``` -------------------------------- ### Set Custom Starting Page via Shortcode Source: https://gravitywiz.com/documentation/gravity-forms-multi-page-navigation Use the 'page' parameter within the Gravity Forms shortcode to set a specific starting page for the form. ```shortcode [gravityforms id="123" page="2"] ``` -------------------------------- ### WP-CLI Command: Get Specific Booking Details Source: https://gravitywiz.com/documentation/gravity-forms-bookings Retrieve detailed information for a specific booking by providing its ID. ```bash wp gp-bookings booking get bookingID ``` -------------------------------- ### Global Filename Template Example Source: https://gravitywiz.com/documentation/gpfr_filename This example demonstrates how to set a global filename template using `gpfr_filename_template`. It places files in an entry-specific subfolder and appends a count to the filename. Requires GP File Renamer v1.0.5+. ```php Head Back to Page #1 ``` -------------------------------- ### Example: Enable User-Agent Checking for Form ID 123 Source: https://gravitywiz.com/documentation/gpcb_validate_user_agent This example demonstrates how to enable user-agent checking for a specific form (ID 123) using the gpcb_validate_user_agent filter. Ensure you update '123' to your target form's ID. ```php Get On Back to Page #2 ``` -------------------------------- ### PHP Snippet Example Source: https://gravitywiz.com/documentation/managing-snippets Most WordPress snippets are written in PHP. PHP snippets typically start with 'get_id()} status changed: {$old_status} -> {$new_status}"); }, 10, 3); ``` -------------------------------- ### JSONPath Slice with Step Source: https://gravitywiz.com/documentation/gravity-connect-api-alchemist Extract elements from an array with a specified step. This example gets every second book title within the first three books in 'store.book'. ```jsonpath $.store.book[0:3:2].title ``` -------------------------------- ### JSONPath Conditional Filtering Source: https://gravitywiz.com/documentation/gravity-connect-api-alchemist Filter array elements based on a condition and retrieve a specific property from the matching elements. This example gets the 'id' from 'items' where the 'active' property is true. ```jsonpath $.items[?(@.active)].id ``` -------------------------------- ### Basic Usage of gpls_before_query Source: https://gravitywiz.com/documentation/gpls_before_query This snippet demonstrates the basic structure for hooking into the 'gpls_before_query' action. It shows how to register a custom function that receives the GPLS_RuleTest object. ```php add_action( 'gpls_before_query', 'my_custom_function' ); ``` -------------------------------- ### Apply gspc_init_args Globally Source: https://gravitywiz.com/documentation/gspc_init_args Use this filter to modify the initialization arguments for the Product Configurator across your entire site. Applied globally. ```php add_filter( 'gspc_init_args', 'my_custom_function' ); ``` -------------------------------- ### List Available Gravity Wiz Packages Source: https://gravitywiz.com/documentation/installing-plugins-with-composer Use this command to see all available Gravity Wiz plugins in the Composer repository. ```bash composer show -all "gravitywiz/*" ``` -------------------------------- ### Register Additional Database for Populate Anything Source: https://gravitywiz.com/documentation/gravity-forms-populate-anything Use this snippet to register an additional SQL database with custom credentials for Populate Anything to pull data from. ```php add_filter( 'gppa_database_connections', function( $connections ) { $connections[] = array( 'label' => 'My Other Database', 'host' => 'localhost', 'user' => 'username', 'password' => 'password', 'database' => 'database_name' ); return $connections; } ); ``` -------------------------------- ### Set default page to the second page Source: https://gravitywiz.com/documentation/gpmpn_default_page This example sets the default page to the second page of the form, overriding any shortcode or query string settings. Update the return value to change the starting page. ```php add_reason( 'admin_role_not_allowed', 'Admin emails are not allowed.' ); } return $validation_result; }, 10, 5 ); ``` -------------------------------- ### Set JPEG Quality to 100% for All Uploaded Images Source: https://gravitywiz.com/documentation/gpfup_jpeg_quality This example demonstrates how to set the JPEG quality to 100% for all images uploaded through File Upload Pro. Ensure you have the Custom Javascript for Gravity Forms plugin installed. ```javascript /** * Gravity Perks // File Upload Pro // Set JPEG Quality for all Uploaded Images * https://gravitywiz.com/documentation/gravity-forms-file-upload-pro/ * * Instructions: * 1. Install our free Custom Javascript for Gravity Forms plugin. * Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/ * 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin. */ window.gform.addFilter( 'gpfup_jpeg_quality', function () { // Update '1' to the desired quality. 1 represents 100%. return 1; } ); ``` -------------------------------- ### Usage of gpld_after_set_min_date Action Source: https://gravitywiz.com/documentation/gpld_after_set_min_date This snippet demonstrates how to hook into the `gpld_after_set_min_date` action to execute a custom function when a minimum date is set. ```javascript gform.addAction( 'gpld_after_set_min_date', 'my_custom_function' ); ``` -------------------------------- ### Reset Unique ID Sequence at Threshold Source: https://gravitywiz.com/documentation/gpui_unique_id This example demonstrates how to reset a sequentially generated Unique ID when it reaches a specific number. Update the form ID, field ID, starting number, and reset threshold as needed. ```php set_sequential_starting_number( $form_id, $field_id, $starting_number - 1 ); } } return $unique; }, 10, 3 ); ``` -------------------------------- ### Registering a Callback for gpb_status_transitioned Source: https://gravitywiz.com/documentation/gpb_status_transitioned Use this action to hook into the booking status transition process globally. Ensure your callback function is defined before adding the action. ```php add_action( 'gpb_status_transitioned', 'my_custom_function' ); ``` -------------------------------- ### Set Limit Period by User Meta Source: https://gravitywiz.com/documentation/gpls_before_query This example shows how to dynamically set the time period for submission limits based on a user's meta data. Ensure the form ID and user meta key are updated to match your specific setup. ```php form_id != 123 ) { return; } // Update "subscription_start_date" to your user meta key. $subscription_start_date = get_user_meta( get_current_user_id(), 'subscription_start_date', true ); $time_period_sql = $wpdb->prepare( 'date_created BETWEEN %s AND DATE_ADD( CURDATE(), INTERVAL 1 DAY )', $subscription_start_date ); $ruletest->where[] = $time_period_sql; } ); ``` -------------------------------- ### Attach a File using gpeu_email_options Source: https://gravitywiz.com/documentation/gpeu_email_options This example demonstrates how to add an attachment to an email by modifying the 'attachment' key within the email options array. Ensure the file path is correct. ```php add_filter( 'gpeu_email_options', function( $options, $form ) { $options['attachment'] = array( 'path/to/file' ); return $options; }, 10, 2 ); ``` -------------------------------- ### Display User Data with Entry Blocks Source: https://gravitywiz.com/documentation/gravity-forms-entry-blocks Utilize the `{created_by:[meta_key]}` merge tag to display user data, including custom meta keys, from the entry creator. For example, `{created_by:first_name}` displays the user's first name. More details are available in the merge tag usage guide. ```php {created_by:first_name} ``` -------------------------------- ### Grant Access to Administrators Source: https://gravitywiz.com/documentation/gpsa_has_access This example demonstrates how to automatically grant access to all content for users with the 'administrator' role. This is useful for ensuring administrators can always view protected content. ```php get_id()} transitioning from {$old_status} to {$new_status}"); return $allowed; }, 10, 4); ``` -------------------------------- ### Configure Composer Authentication Source: https://gravitywiz.com/documentation/installing-plugins-with-composer Set up basic authentication for the Gravity Wiz Composer repository using your license keys and registered site URL. ```bash composer config -g http-basic.gravitywiz.com **"[LICENSE_KEY(S)]" "[REGISTERED_SITE]"** ``` -------------------------------- ### Customize Out of Stock Message Source: https://gravitywiz.com/documentation/gpi_out_of_stock_message Example of how to return a custom out-of-stock message using the `gpi_out_of_stock_message` filter. This example sets a static message. ```php add_filter( 'gpi_out_of_stock_message', function(){ return 'Sorry, this item is out of stock.'; } ); ``` -------------------------------- ### WP-CLI Command: List All Bookings Source: https://gravitywiz.com/documentation/gravity-forms-bookings Use this command to retrieve a list of all bookings managed by GP Bookings. ```bash wp gp-bookings booking list ``` -------------------------------- ### Calculate Date Difference Including Both Start and End Dates Source: https://gravitywiz.com/documentation/gravity-forms-date-time-calculator Use `includeStart=true` and `includeEnd=true` with `datediff()` to count both the start and end dates in the calculation. ```php datediff( F1, F2, unit='days', includeStart=true, includeEnd=true ) ``` -------------------------------- ### Add Live Merge Tag to Whitelist Source: https://gravitywiz.com/documentation/gppa_lmt_whitelist This example demonstrates how to add a specific Live Merge Tag (e.g., '{ip}') to the whitelist for a given form. It ensures that the merge tag is recognized and can be used. ```php get_id() === 123 && date( 'N', strtotime( $date ) ) === '5' ) { return 60; } return $block_size; }, 10, 3 ); ``` -------------------------------- ### Custom Inventory Exhausted Message Example Source: https://gravitywiz.com/documentation/gpi_inventory_exhausted_message This example demonstrates how to return a custom string for the inventory exhausted message. This filter is available since Gravity Forms Inventory 1.0-beta-3.42. ```php add_filter( 'gpi_inventory_exhausted_message', function() { return "Sorry, item out of stock."; } ); ``` -------------------------------- ### Define License Keys in wp-config.php Source: https://gravitywiz.com/documentation/can-i-download-perks-via-an-api Define license key constants in wp-config.php before installation to automatically pre-populate them. This method applies to Perks, Connect, and Shop licenses. ```php define( 'SPELLBOOK_KEY_PERKS', 'YOUR-GRAVITY-PERKS-LICENSE-KEY-HERE' ); define( 'SPELLBOOK_KEY_CONNECT', 'YOUR-GRAVITY-CONNECT-LICENSE-KEY-HERE' ); define( 'SPELLBOOK_KEY_SHOP', 'YOUR-GRAVITY-SHOP-LICENSE-KEY-HERE' ); ``` -------------------------------- ### Populate All Results Source: https://gravitywiz.com/documentation/gravity-forms-populate-anything Enables Populate Anything to populate all found results, not just the first one. ```php add_filter( 'gppa_limit_YOUR_FIELD_ID', '__return_false' ); ``` -------------------------------- ### Remove 'Start New Draft' Link Source: https://gravitywiz.com/documentation/gravity-forms-advanced-save-and-continue Use this filter to remove the 'Start New Draft' link. To apply to all forms, use 'gpasc_new_draft_link_text'. To apply to a specific form, append the form ID. ```php add_filter( 'gpasc_new_draft_link_text', '__return_false' ); ``` ```php add_filter( 'gpasc_new_draft_link_text_FORMID', '__return_false' ); ``` -------------------------------- ### Example Auto-Progression Condition for Text Fields Source: https://gravitywiz.com/documentation/gppt_auto_progress_support_conditions This example demonstrates a condition for 'text' field types, requiring the Input Mask feature to be enabled for auto-progression support. It's provided as an illustration of how a callback function works. ```php array( 'type' => 'text', 'callback' => array( $this, 'auto_progress_condition_text' ), ) ``` ```php public function auto_progress_condition_text( $field ) { return $field['inputMask'] == true; } ``` -------------------------------- ### Register gpb_pre_status_transition Filter Source: https://gravitywiz.com/documentation/gpb_pre_status_transition This is the basic structure for hooking into the gpb_pre_status_transition filter. Replace 'my_custom_function' with your actual callback function name. ```php add_filter( 'gpb_pre_status_transition', 'my_custom_function' ); ``` -------------------------------- ### Count Weekdays Between Two Dates Source: https://gravitywiz.com/documentation/gravity-forms-date-time-calculator?migration=1 Use the `{weekdays:}` merge tag to count the number of weekdays between two specified Date fields. The count includes the start date. Subtract 1 to exclude the start date. ```gravityforms {weekdays:{Start Date:1},{End Date:2}} ``` -------------------------------- ### Change Validation Message for a Specific Field (Example) Source: https://gravitywiz.com/documentation/gpls_field_validation_message This example demonstrates how to change the GP Limit Submission validation message for field ID `4` in form ID `123`. Update the IDs and the message string as needed. ```php get_id() === 123 ) { return \Carbon\CarbonImmutable::today()->addYear(); } // Haircuts: 2 months advance if ( $service->get_id() === 456 ) { return \Carbon\CarbonImmutable::today()->addMonths( 2 ); } return $end; }, 10, 3 ); ``` -------------------------------- ### Restrict Bookings When a Specific Resource is Selected Source: https://gravitywiz.com/documentation/gpb_availability_start Apply different restrictions based on which resource is being booked. This example requires 1 week advance notice if resource ID 456 is selected. ```php add_filter( 'gpb_availability_start', function( $start, $service, $resource_ids ) { // Premium resource requires 1 week advance notice if ( in_array( 456, $resource_ids ) ) { return \Carbon\CarbonImmutable::today()->addWeeks( 1 ); } return $start; }, 10, 3 ); ``` -------------------------------- ### Count Weekend Days Between Two Dates Source: https://gravitywiz.com/documentation/gravity-forms-date-time-calculator?migration=1 Use the `{weekendDays:}` merge tag to count the number of weekend days between two specified Date fields. The count includes the start date. Subtract 1 to exclude the start date. ```gravityforms {weekendDays:{Start Date:1},{End Date:2}} ``` -------------------------------- ### Sample Gravity Forms HTML Structure Source: https://gravitywiz.com/documentation/gravity-forms-popups Provides a sample HTML structure for a Gravity Form, illustrating the common classes and elements used by the plugin, such as `.gform_wrapper`, `.gform_body`, `.gfield`, and `.gform_footer`. ```html
``` -------------------------------- ### Set Orphaned Entry Expiration Duration Source: https://gravitywiz.com/documentation/gpnf_expiration_modifier This snippet demonstrates setting custom expiration durations for orphaned entries. The first example sets expiration to 30 days (1 month), and the second example sets it to never expire by returning a very large value. ```php esc_html__( 'Menu Order', 'gp-populate-anything' ), 'value' => 'menu_order', 'callable' => array( gp_populate_anything()->get_object_type( 'post' ), 'get_col_rows' ), 'args' => array( $wpdb->posts, 'menu_order' ), 'orderby' => true, ); return $props; } ); ```