Advanced Relationship

The Relationship field includes new settings allowing users to create and edit post on-the-fly from the post edit screen.

Field Group
      Add New

      Field Settings

      Setting nameDescription
      Allow Post CreationAllow the user to create post in a modal. Allowed post types are based on the “Filter by Post Type” setting.
      Allow Post EditAllow the user to edit the post in a modal.

      Iframe Arguments

      The iframe which handle the post creation and edit will use URL parameters, allowing developers to use them.

      https://www.domain.com/wp-admin/post-new.php?post_type=post&acfe_relation_type=add&acfe_relation_field_cid=acf129&acfe_relation_field_key=field_63c7834ac15e2&acfe_relation_field_name=post_object&acfe_relation_post_id=270&acfe_relation_is_admin=1
      /**
       * acfe_relation_type=add                      // action type (add/edit)
       * acfe_relation_field_key=field_63c7834ac15e2 // field key
       * acfe_relation_field_name=relationship       // field name
       * acfe_relation_post_id=270                   // original post id
       * acfe_relation_is_admin=1                    // original request from admin
       */

      It is possible to retrieve these arguments using $_GET or the acf_maybe_get_GET() function. Usage example:

      add_filter('acf/prepare_field/name=my_field', 'my_prepare_field');
      function my_prepare_field($field){
          
          // hide the field if inside the relationship iframe
          // originated from the front-end
          if(acf_maybe_get_GET('acfe_relation_is_admin') === '0'){
              return false;
          }
      
          // return normally
          return $field;
      
      }

      Video Showcase