WordPress.org

Plugin Directory

Changeset 1475147


Ignore:
Timestamp:
08/16/16 05:19:22 (10 months ago)
Author:
cyrilbatillat
Message:

Some more FAQ about bidirectional fields and pre-populating child fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quick-and-easy-post-creation-for-acf-relationship-fields/trunk/readme.txt

    r1463314 r1475147  
    5555= Can we make the lightbox wider? = 
    5656 
    57 Unfortunately not for the moment. This will be a possible enchancement when [this bug](https://core.trac.wordpress.org/ticket/27473 "See the bug ticket") will be fixed. 
     57Unfortunately not for the moment. This will be a possible enhancement when [this bug](https://core.trac.wordpress.org/ticket/27473 "See the bug ticket") will be fixed. 
     58 
     59= Does this add-on handle bidirectional relationships? = 
     60 
     61Bidirectional relationships are out of the scope of this add-on. However, [the ACF documentation](https://www.advancedcustomfields.com/resources/bidirectional-relationships/) gives a great example to achieve this. 
     62 
     63= Is it possible to pre-populate a child field depending on the parent from where it’s been created? = 
     64 
     65Yes it is. This add-on loads the child post form in an iframe with some additional URL params: 
     66 
     671. acf_rc_from_content_type: the post type of your parent post. 
     681. acf_rc_from_content_ID: the ID of your parent post. 
     69 
     70You can use these URL params to pre-populate an ACF field on your child post. Example: 
     71 
     72> <?php 
     73> add_filter('acf/load_field/name=${NAME_OF_YOUR_ACF_FIELD}', 'populate_acf_field' ); 
     74> function populate_acf_field( $field ) { 
     75>     if( !empty( $_REQUEST['acf_rc_from_content_type'] ) && $_REQUEST['acf_rc_from_content_type'] == '${YOUR_PARENT_CONTENT_TYPE}' && !empty( $_REQUEST['acf_rc_from_content_ID'] ) ) { 
     76>         $field['value'] = 'whatever you want'; 
     77>     } 
     78>     return $field; 
     79> } 
     80 
    5881 
    5982== Screenshots == 
Note: See TracChangeset for help on using the changeset viewer.