Support

Account

Forum Replies Created

  • ok i’ll give it a shot if you say so,
    I still need the answer about using acf_form for create not edit.
    I hope you understood my posts and suggested live edit because you have added live-create on top of live-edit

    I also like to keep my site lean, only adding something when there is noway to do with what i have.So if there is actually an acf_form way to add the_content and the_title please document it for people to read.

  • another post!
    Hay LiveEdit seems to do the job just fine and look pro-like.
    No frontier-post needed.It would do a fine job to edit posts but I still need create post more than edit!Is that included?(I am developing a company site that will have a problem post page for its customers including CF!)I am mostly interested in add post but edit post would be a nice touch

    So how should I add a create post_title and post_content fields using an acf_form or Live edit?(I think the live edit tut included only an edit button) .

  • what i am trying to do is roughly what the ‘frontier-post’ plug-in offers, which is less integrated with wordpress but offers this very detail:a postlist with edit link that changes a posts’ standard and custom fields

    Do you think the two plug-ins will work together?I just checked you can access customfields simply by the_field('mycustomfield')…Does get_field(...) work as well?How about something that would be called set_field or better could someone access the values of a combobox and the datepickers from html and/or php to perform an update without using the acf_form if it doesn’t offer this very detail

    I wanted to skip changing php though, especially in a responsive site. So how could someone achieve what frontier-post offers?

  • Let’s start with a ref,I am trying to follow tutorial:http://www.advancedcustomfields.com/resources/tutorials/creating-a-front-end-form/

    Clarifiaction when I say I am setting 'post_id' => $post->ID to a specific number i mean changing this to 'post_id' => 464 found on permalink AND added $options variable to the same file of the themes’templates’ php code.

    That works, however you normally need to set the post_id from a page that queries wp_query and comes up with $post=>ID. You also normally need not to use the <?php the_post(); ?> and instead add a textarea or WYSIWYG to actually change the content&title.( i guess with the html_after_fields property/attribute)

    It is extraordinary and seems improbable that you took spended so much effort to render acf_form and not have included standardfields, so please check your referrences and documentation for any hints or refferences

    I also needed to display a list of posts with an edit link to point to the page using the template that will ‘fetch’ the $post=>ID

  • I also thought you may need to now my purpose before answering my question. In the end, I’dlike to show the_post and have a button in case you are the author and enable editing.

    If all fails I will enable only the create post but it’s a nice touch not tobe dependent on the back-end of wordpress

  • i did myself a bit of resolving the problem just from the tutorial.Problem was I am using Customizr template which is quite more complex than twentytwelve and, clumsy as i am, i copied from tutorial.

    Anyway fields seem to appear now.However only if i set post id to a number on the template.Is this automated?I mean If i make a wpquery to fetch a post on the page, will the template take over and automate editing?I guess yes but awaiting for your answer…

    Also can you give an example of a standard field html to use in ‘html_after_fields’ say the content field.(Why use the_post when you want to show it editable?)

    Can you provide me with referrences for these questions?
    I think after that I will consider my problem(s) solved

  • *Answers to questions:
    by page i mean the stdandard type of wordpress where you type in the textarea (text or visual) the html+images+shortcodes for your static pages in your site.
    However it is possible to include php in a page with different plugins so you may write a snippet of code that queries wordpress in its language or even SQL.

    By template I mean the theme’s default layouts that are to contain widgets.In the specific tutorial (create new post)code is added to the templates.

    *Questions answered correctly: I may use html beforefields to include standard fields(Can you provide me with an example say for the field:post_content?)

    I understand that i may use firebug to see Css in effect.But it would be convenient to add a class to the custom fields and give it priority…Is this another line in $args just like in the $options in editpost tutorial/example

    *Issues uncovered:I still get a blank(we defined what blank is) when viewing a page that is linked to the editpost template.How could one use php to query wordpress (WP_query) to get post_id and then display the appropriate customfields and filled in standard fields?

  • last message I wrote before getting your post: let me recapitulate…
    I was always speaking about the new post not the edit post…
    initially I put the $args code on the page that was made with the template!

    Because I thought it would be similar to edit post tut where you definately need to put the $options code on the page, not the template because it should look different for different posts.

    Well, It did not work and then I wrote this post, partly because we have another visitor,lucien, to tell him he needs to put all the code on the template.So that’s what I meant

    I am still stuck with the edit post tutorial that brings nothing on screen;blank.

    How should I work around the edit post and the styling of labels and comboboxes and datepickers?

  • thanx E,
    now how about adding a class to $args (and/or how labels,datepickers,combos are accessed -IDs classnames etc)

    Using the code U suggested, I can see the new-post form with only the custom fields.How can U add standard post fields like content,excerpt,title at least.

    Should I add lines in core/api.php? Any tutorial about filters

  • for lucian,
    I think the trick is to put all the code in the template, nothing on the page.
    so you may need to retry

    However this is not the case with edit form tut.
    You have to get the post Id from the page not the template i guess
    and edit it appropriately…
    I get blank in that case while putting the $options array in the template
    I get a 500 internal server error
    ideas, E?

  • HI,
    I REDID THE STEPS CAREFULLY AND MANAGED TO GET THE CUSTOM FIELDS ALONE IN A PREETY UGLY SHAPE.

    is there any CSS to enable changing the looks of it as well as html/php for including the standard fields like title and description?

    i think this should be added to the tutorial

    Thanx E,
    I finally got somewhere but my questions are still pending

  • Q:Are you trying to ‘edit’ an existing post?A:both but let’s start at create…

    The code from the documentation

    	$args = array(
    				'post_id' => 'new',
    				'field_groups' => array(109,108 )
    			);
     
    			acf_form( $args ); 

    was used.

    there is no form fields,no custom fields just a submit button with ‘Update’ caption.

    I tested combinations of using the $args def. & acf_form($args)
    php code in both the template and the page.No improovement.

    (I followed the guidelines and included acf_form_head(); php code on the
    template just before get_header(); and also added code to theme functions.php as in documentation.)

  • My first posts were about both of the tutorials(the code has very minor differences from the suggested code in the tutorials). The problem is the same. I saw the header and sidebar of the customizr theme but in the content area nothing,blank.

    In create post there appears only a submit button but no fields, custom or not

  • OK I DID THAT, NOW MY CODE LOOKS LIKE

    
    <phpcode><?php
    $options = array(
        'post_id' => 377, // post id to get field groups from and save data to
        'field_groups' => array(109,108 ), // this will find the field groups for this post (post ID's of the acf post objects)
        'form' => true, // set this to false to prevent the <form> tag from being created
        'form_attributes' => array( // attributes will be added to the form element
            'id' => 'post',
            'class' => '',
            'action' => '',
            'method' => 'post',
        ),
        'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url
        'html_before_fields' => '', // html inside form before fields
        'html_after_fields' => '', // html inside form after fields
        'submit_value' => 'Update', // value for submit field
        'updated_message' => 'Post updated.', // default updated message. Can be false to show no message
    );
    acf_form( $options ); 
    ?></phpcode>
    

    THE RESULT IS BLANK…MAYBE MY PHPCODE PLUGIN ISN’T COMBATIBLE,SUGGESTIONS?
    PLEASE ANSWER ALSO IF ACFFORM HANDLES STANDARD FIELDS
    (I HAVE ALTERED POST,NOT CREATED NEW POSTTYPE)

  • ..as an extention to the first question today, can you suggest a form plugin that is combatible with ACF?
    (in case your acf form shortcode does not complete the whole feedback form task)

  • hi, E
    can you tell me how to locate the fieldgroup ID

    I think though, that this is not the case
    There are two tutorials in your plugin site
    One for new post, one for edit post
    In the addpost tutorial you are instructed to leave the customfields property empty.

    Again there might be some misunderstanding, is the code there to just add the customfields in a form(how to create such a form in html/php? ) or will it include custom/normal post-type fields created as a holistic solution

    There are competitive sites that do the trick but they are not free and constraining, I want control&free…so can you please helpme- you will have another fan 🙂

  • that’s a good idea.How do I find the IDs of the fieldgroups I created.

    I also don’t understand the following comment; maybe it’s crucial
    // this will find the field groups for this post (post ID’s of the acf post objects).
    Why do I have to get security rules & fields from a random post when it should be that the post obeys to rules created. ie admin sees all custom fields, authors see one.

    does Implementing the ACF form to edit a post includes standard fields like body/categories,etc ? If it does can you enable/disable fields?

  • Hi, E.
    Let’s narrow down the focus since i posted code for add/edit in paralllel. First in theme’s functions, then in the pages, last in the templates.

    Now let’s focus on edit(uses $options while create uses $args).Specifically, the code used(included in a messy way in my first post) is:

    <?php
    $options = array(
        'post_id' => 213, // post id to get field groups from and save data to
        'field_groups' => array('Συνδιασμοί αναρτήσεων','Τύπος αναρτήσεων' ), // this will find the field groups for this post (post ID's of the acf post objects)
        'form' => true, // set this to false to prevent the <form> tag from being created
        'form_attributes' => array( // attributes will be added to the form element
            'id' => 'post',
            'class' => '',
            'action' => '',
            'method' => 'post',
        ),
        'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url
        'html_before_fields' => '', // html inside form before fields
        'html_after_fields' => '', // html inside form after fields
        'submit_value' => 'Update', // value for submit field
        'updated_message' => 'Post updated.', // default updated message. Can be false to show no message
    );
     
    ?>

    Recall, nothing is displayed (i also did steps to add somefunction to theme functions)

  • hi,E you seem ver helpfull and the plugin is good . congrats.
    Now here is the problem I face.The code is as is found on the links.only minor modifications are performed
    First link/piece of code:create post form is the title of the tut. How do I need to modify it to actually visualize all fields in a contact form based on rules.

    Link 2: same problem;only the submit button appears.(the code is meant to edit a post and ‘get fields from post’.How’s that; i modified post ; I did not added a custom post type.So will a contributor and admin and guest be detected and the correct fields be presented?

    Link3: I hope it is better integration to use your tutorials found on links.But if not or if you can allocate resources to help me please answer how will the presented fields be selected, or if that would be(maybe it is) too much just inform me of a quick-fix to get values to the custom fields and i will re-produce a select control myself

  • encouragement 2 gurus : That might seem like a load of trouble for a volunteer 2 change. But it isn’t solutions can be given with a couple of lines EITHER wit acf working template OR with some css/widget for php. Just a workaround for post customfields in a WPconsistent way

  • I did not want to dump the forum with loads of code but since eliot suggested I do as instruced
    So here goes…

    In theme’s functions.php I added (for the next two solutions(links included))

    function my_pre_save_post( $post_id )
    {
    // check if this is to be a new post
    if( $post_id != ‘new’ )
    {
    return $post_id;
    }

    // Create a new post
    $post = array(
    ‘post_status’ => ‘draft’ ,
    ‘post_title’ => ‘A title, maybe a $_POST variable’ ,
    ‘post_type’ => ‘post’ ,
    );

    // insert the post
    $post_id = wp_insert_post( $post );

    // update $_POST[‘return’]
    $_POST[‘return’] = add_query_arg( array(‘post_id’ => $post_id), $_POST[‘return’] );

    // return the new ID
    return $post_id;
    }

    add_filter(‘acf/pre_save_post’ , ‘my_pre_save_post’ );

    function my_deregister_styles() {
    wp_deregister_style( ‘wp-admin’ );
    }

    add_action( ‘wp_print_styles’, ‘my_deregister_styles’, 100 );
    ********************************************************
    pages using the two templates have the following extra <phpcode> code

    <phpcode><?php
    $args = array(‘post_id’ => ‘new’,’field_groups’ => array(‘Συνδιασμοί αναρτήσεων’,’Τύπος αναρτήσεων’ ));
    ?></phpcode>

    **** and

    <phpcode><?php
    $options = array(
    ‘post_id’ => 213, // post id to get field groups from and save data to
    ‘field_groups’ => array(‘Συνδιασμοί αναρτήσεων’,’Τύπος αναρτήσεων’ ), // this will find the field groups for this post (post ID’s of the acf post objects)
    ‘form’ => true, // set this to false to prevent the <form> tag from being created
    ‘form_attributes’ => array( // attributes will be added to the form element
    ‘id’ => ‘post’,
    ‘class’ => ”,
    ‘action’ => ”,
    ‘method’ => ‘post’,
    ),
    ‘return’ => add_query_arg( ‘updated’, ‘true’, get_permalink() ), // return url
    ‘html_before_fields’ => ”, // html inside form before fields
    ‘html_after_fields’ => ”, // html inside form after fields
    ‘submit_value’ => ‘Update’, // value for submit field
    ‘updated_message’ => ‘Post updated.’, // default updated message. Can be false to show no message
    );

    ?></phpcode>
    ********************************************************
    i am not sure I modified the $args and $options correctly but I did a couple
    of attempts.I also don’t get the concept of how can we get fields from post(How’s that when you create a new post OR how will it edit a post not defined in code (ie 213) which took the place of $post->ID (although i figured that this can be implied if a wp_query is ran having effect on global(?) variables .(please explain)
    ********************************************************

    Then I created a couple of php templates in theme editor

    in themes form_create.php I added
    (found on http://www.advancedcustomfields.com/resources/tutorials/using-acf_form-to-create-a-new-post/)
    ********************************************************
    <?php

    /**
    * Template Name: Page with ACF form
    */

    acf_form_head();

    get_header();

    the_post();

    ?>

    <div id=”primary”>
    <div id=”content” role=”main”>

    <?php

    $args = array(
    ‘post_id’ => ‘new’,
    ‘field_groups’ => array(‘Συνδιασμοί αναρτήσεων’,’Τύπος αναρτήσεων’ )
    );

    acf_form( $args );

    ?>

    </div><!– #content –>
    </div><!– #primary –>

    in themes form_edit.php I added
    (found on http://www.advancedcustomfields.com/resources/tutorials/creating-a-front-end-form/)
    ********************************************************

    <?php

    /**
    * Template Name: Form Page
    */

    acf_form_head();

    get_header(); ?>

    <div id=”primary”>
    <div id=”content” role=”main”>

    <?php the_post(); ?>

    <?php acf_form( $options ); ?>

    </div><!– #content –>
    </div><!– #primary –>

    Finally in a page I tried a php code -for posting(that worked with ordinary post fields but not custom fields)I’dlike a consistent solution.
    ********************************************************
    <?php
    /*
    Template Name: Post publish form
    */

    ?>
    <?php
    if( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] && !empty( $_POST[‘action’] ) && $_POST[‘action’] == “new_post”) {

    // Do some minor form validation to make sure there is content
    if (isset ($_POST[‘title’])) {
    $title = $_POST[‘title’];
    } else {
    echo ‘Προσθέστε Τίτλο πριν την ανάρτηση’;
    }
    if (isset ($_POST[‘description’])) {
    $description = $_POST[‘description’];
    } else {
    echo ‘Προσθέστε Περιεχόμενο της ανάρτησης’;
    }

    $tags = $_POST[‘post_tags’];

    // ADD THE FORM INPUT TO $new_post ARRAY
    $new_post = array(
    ‘post_title’ => $title,
    ‘post_content’ => $description,
    ‘post_category’ => array($_POST[‘cat’]), // Usable for custom taxonomies too
    ‘tags_input’ => array($tags),
    ‘post_status’ => ‘publish’, // Choose: publish, preview, future, draft, etc.
    ‘post_type’ => ‘post’, //’post’,page’ or use a custom post type if you want to
    ‘_product’=>$fproduct
    );

    //SAVE THE POST
    $pid = wp_insert_post($new_post);

    //KEEPS OUR COMMA SEPARATED TAGS AS INDIVIDUAL
    wp_set_post_tags($pid, $_POST[‘post_tags’]);

    //REDIRECT TO THE NEW POST ON SAVE
    //wp_redirect( ‘/publikation/’ );

    //ADD OUR CUSTOM FIELDS
    add_post_meta($fproduct, ‘_product’, true);

    //INSERT OUR MEDIA ATTACHMENTS
    if ($_FILES) {
    foreach ($_FILES as $file => $array) {
    $newupload = insert_attachment($file,$pid);
    // $newupload returns the attachment id of the file that
    // was just uploaded. Do whatever you want with that now.
    }

    } // END THE IF STATEMENT FOR FILES

    } // END THE IF STATEMENT THAT STARTED THE WHOLE FORM

    //POST THE POST YO
    do_action(‘wp_insert_post’, ‘wp_insert_post’);

    ?>
    <div id=”content” role=”main”>

    <div class=”form-content”>

    <!– ΦΟΡΜΑ ΑΝΑΡΤΗΣΗΣ ΠΡΟΒΛΗΜΑΤΑ –>

    <div class=”wpcf7″>
    <form id=”new_post” name=”new_post” method=”post” action=”” class=”wpcf7-form” enctype=”multipart/form-data”>
    <!– post name –>
    <fieldset name=”name”>
    <label for=”title”>Τίτλος</label>
    <input type=”text” id=”title” value=”” tabindex=”5″ name=”title” />
    </fieldset>

    <!– post Category –>
    <fieldset class=”category”>
    <label for=”cat”>Κατηγορία</label>
    <?php wp_dropdown_categories( ‘tab_index=10&taxonomy=category&hide_empty=0’ ); ?>
    </fieldset>

    <!– post Content –>
    <fieldset class=”content”>
    <label for=”description”></label>
    <textarea id=”description” tabindex=”15″ name=”description” cols=”80″ rows=”10″></textarea>
    </fieldset>

    <fieldset class=”_product”>
    <label for=”description”>Προιόν</label>
    <input type=”text” id=”fproduct” value=”” tabindex=”5″ name=”fproduct” />

    </fieldset>
    <!– post tags –>
    <fieldset class=”tags”>
    <label for=”post_tags”>Tags</label>
    <input type=”text” value=”” tabindex=”35″ name=”post_tags” id=”post_tags” />
    </fieldset>

    <fieldset class=”submit”>
    <input type=”submit” value=”Ανάρτησέ το” tabindex=”40″ id=”submit” name=”submit” />
    </fieldset>

    <input type=”hidden” name=”action” value=”new_post” />
    <?php wp_nonce_field( ‘new-post’ ); ?>
    </form>
    </div> <!– END WPCF7 –>

    <!– END OF FORM –>
    </div><!– .entry-content –>
    </div><!– #post-## –>

    **************************************************************************
    that code is working but I want a consistent solution both in terms of security(moderation) and also GUI-integration and getting initialized with ie select values for entry and a datepicker etc .Remember I have not created a custom post-type and altered standard post for different roles.How can I create a form including different fields for different roles/rules?

  • i just understood we can’t escape definging fields in html/php. pity .including all defined fields for rules in effect would be a nice shortcode for acf_form to implement

    if anyone knows the answer can he help modifying
    http://wordpress.org/support/topic/frontend-post-submission-form
    for custom fields

Viewing 22 posts - 1 through 22 (of 22 total)