Code Monkey home page Code Monkey logo

gravity-forms-acf-field's Introduction

Gravity-Forms-ACF-Field

This is an Advanced Custom Field custom field to select one or many Gravity Forms.

This provides a field that lets you select from a list of active Gravity Forms.

Compatibility

This add-on will work with:

  • version 4 and up
  • version 3 and below

Installation

This add-on can be treated as both a WP plugin and a theme include.

Plugin

  1. Copy the 'Gravity-Forms-ACF-field' folder into your plugins folder
  2. Activate the plugin via the Plugins admin page

Include

  1. Copy the 'Gravity-Forms-ACF-field' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory
  2. Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-gravity_forms.php file)
add_action('acf/register_fields', 'my_register_fields');

function my_register_fields()
{
  include_once('acf-gravity_forms.php');
}

Using the field

The field lets you pick one or many fields.

The data returned is either a Form object or an array of Form objects.

If you have selected a single form and you want to display the form on the page, you can use:

<?php 
    $form = get_field('your_form_field');
    gravity_form_enqueue_scripts($form->id, true);
    gravity_form($form->id, true, true, false, '', true, 1); 
?>

You can find out more about the gravity_form method to embed a form on a page in their documentation

If you are using the field to select multiple forms, you will have to iterate over the array. You can then use the form object as you like:

<?php
    $forms = get_field('your_forms');
  
    foreach($forms as $form){
        echo $form->title;  
    }
?>

About

Version: 1.0

Written by Adam Pope of Storm Consultancy - http://www.stormconsultancy.co.uk

Storm Consultancy are a web design and development agency based in Bath, UK.

If you are looking for a Bath WordPress Developer, then get in touch!

Credits

Thanks for Lewis Mcarey for the Users Field ACF add-on on which we based this - https://github.com/lewismcarey/User-Field-ACF-Add-on

Thanks to rocketgenius for the absolutely fantastic Gravity Forms plugin!

gravity-forms-acf-field's People

Contributors

adampope avatar ajmorris avatar dabernathy89 avatar lgladdy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.