bostondv/acf-ninja-forms 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bostondv/acf-ninja-forms

Composer 安装命令:

composer require bostondv/acf-ninja-forms

包简介

Adds an Advanced Custom Fields field to select one or many Ninja Forms.

README 文档

README

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

Compatibility

  • ACF version 4 and up
  • Ninja Forms version 2.9.X and up

Installation

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

Plugin

  1. Copy the 'acf-ninja-forms' folder into your plugins folder
  2. Activate the Advanced Custom Fields: Ninja Forms Field plugin through the 'Plugins' menu in WordPress

Include

  1. Copy the 'acf-ninja-forms' 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-ninja-forms.php file)
function my_register_fields() {
    include_once( 'acf-ninja-forms.php' );
}
add_action( 'acf/register_fields', 'my_register_fields' );

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:

Ninja Forms 3.X.X

<?php
$form = get_field( 'your_form_field' );
if ( class_exists( 'Ninja_Forms' ) ) {
    Ninja_Forms()->display( $form[ 'id' ] );
}
?>

Ninja Forms 2.9.X

<?php
    $form = get_field( 'your_form_field' );
    if ( function_exists( 'ninja_forms_display_form' ) ) {
        ninja_forms_display_form( $form[ 'id' ] );
    }
?>

You can find out more about the Ninja Forms methods 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[ 'id' ];
    }
?>

About

Made with <3 by Boston Dell-Vandenberg.

Credits

Thanks to Adam Pope for the ACF Gravity Forms and Lewis Mcarey for the Users Field ACF add-ons on which we based this on.

统计信息

  • 总下载量: 25.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固