Home Forums ACF PRO ACF with Social Article Reply To: ACF with Social Article

  • Hi @topy

    Ok, so the steps would be as follows:

    1) create the form group with all the fields you want to be on your post
    2) create a page in wordpress where this form will ‘live’
    3) open your functions.php and add these 2 bits of code:

      /*----------  User Info  ----------*/
      // this creates a global 'USERID' which you can use to return the ID of the current user anywhere in your site
      if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        define('USERID', $current_user->ID);
      /*----------  Check if I am an admin  ----------*/
      function is_administrator() {
        $current_user = wp_get_current_user();
        $roles = $current_user->roles;
        return (in_array('administrator', $roles)) ? true : false;

    4) create a new page template to apply to this page (assuming you know how to do this?)
    5) in that template, put this at the very top of your file:

       *      Is something being edited?
       *      Is the user trying to do this, the author of the post being edited?
       *      If not, redirect back to home
      if (isset($_GET['edit'])) {
        // get the post being edited
        $thispost = get_post($_GET['edit']);
        if (USERID == $thispost->post_author || is_administrator()) {
          $new_post = $_GET['edit'];
        } else {
          header('Location: '.get_bloginfo('home'));
      } else {
        $new_post = 'new_post';
      /* Template Name: My Post Create Page */

    You will use this page for both post creation, and post editing. To edit the post, just add ?edit=23 to the URL and that will let you edit post 23. Note that the above function will only let the author of post 23, or the administrator edit this post. Anyone else will be redirected to the home page

    6) Where you want the edit form to appear, put this code:

      $formoptions = array(
        'post_title'      => true,
        'post_content'    => false,
        'post_id'         => $new_post,
        'new_post'        => array(
          'post_type'       => 'insights', // change this to the post type you need
          'post_status'     => 'publish' // do you want the post to be published immediately? otherwise change this to 'draft'
        'field_groups'    => array(999999), // change this number to the ID of your field group
        'submit_value'    => 'Publish',
        'return'          => get_permalink(142), // change this ID to the page you want to send the user back to when they've submitted the form - perhaps a thank you page
        'uploader'        => 'wp'


    That should do the trick. Give it a go and let me know if you get stuck.

    Good luck!