Support

Account

Home Forums Pre-purchase Questions Can ACF do this? (with Social Article)

Solved

Can ACF do this? (with Social Article)

  • Hi, is it possible to do this?

    I have Social Article to allow users to submit posts. In the Social Article, there’re 4 tabs: Published, Under Review, Draft, New Article.

    1) When clicking on New Article, is it possible to bring users to ACF frontend form that I prepare in another page, where only login users can post? I don’t
    like the default form of Social Article. So, I want to replace it with the form I create with ACF.

    2) And there in ACF frontend form in that page, is it possible to have “Save to Draft” button So that when users save to draft, it goes to the Draft tab in Social Article for users to edit later. And is it possible when users click on submit button there in the ACF form page, it goes to the Under Review tab in social Article. (pending for approval)

    3) In the Published, Under Review, and Draft tabs, there’s an Edit button. Is it possible when users click on the Edit button, it leads to ACF frontend form where they can edit a post with the ACF form, not the default form.

    And If I buy ACF Pro, can you help me with this? Sorry for many questions!

    Thanks.

  • Hiya @topy

    In short, yes everything you describe is doable.

    1) You can create an ACF form and then embed this form onto a page and tell the form that it needs to create a new page, post or custom post type. You can also wrap this code into a check to see if the user is logged in so that only logged in users can access this form.

    2) You can set the form to always create ‘draft’ posts by default. Or alternatively, you can make it a changeable field and combine it with a hook to actually make the post draft or published. I’ve actually recently done this myself. You would have a field in your ACF form called ‘status’. Then you create a hook that is triggered when this form is submitted. It would get the value of that field, and use it to set the status of the post.

    3) The same code that renders the form onto the page from item 1 above, can be used but with a different parameter that edits a post instead of creating a new one.

    For example, on your page where you have the form embedded, right at the top you’d have:

    
    /**
     *      Is something being edited?
     *      Is the user trying to do this, the author of the post being edited, or an admin?
     *      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_administator()) {
        $new_post = $_GET['edit'];
      } else {
        header('Location: '.get_bloginfo('home'));
        exit;
      }
    } else {
      $new_post = 'new_post';
    }
    

    So if your post create page is website.com/new-post then to edit a post using that same form, you’d have website.com/new-post?edit=23 and then you’d be editing post 23.

    And to actually embed the form that uses the logic above, you’d have:

    
    $formoptions = array(
      'post_title'      => true,
      'post_content'    => false,
      'post_id'         => $new_post,
      'field_groups'    => array(256),
      'submit_value'    => 'Publish',
      'return'          => get_permalink(142),
      'uploader'        => 'wp'
    );
    acf_form($formoptions);
    

    Hope this answers your questions and helps you confirm the purchase of ACF. It definitely is an incredible piece of software and worth absolutely every penny 🙂

  • @markbloomfield

    Hi, thanks for your information. Glad to hear that’s possible.But it seems to be doable and easy for a person who knows how to do. But for me, I don’t know. I have been through the forum to read information and also checked the documents, still I don’t understand how to do, for example display a form in frontend. Many people just mention about the code, but I did’t know where to put the code, step by step, not mention clearly. So it’s very hard for me to do. If I buy the plugin wothout solving to my request, then I would end up with nothing because it’s very hard for me to use this plugin.

    Sorry I did’t indicate clearly about the form for login users. I mean I want only the author who creates a post can edit that post, other authors cannot.

    Thanks.

  • Well when that time comes @topy, create a post here, CC me into the post and I’ll help you through.

    That snippet of code I gave in my last post does exactly that – it checks if the current user who’s trying to edit the post, was the author of the post. If so, it’ll let them edit. If not, it’ll redirect to the home page.

    In terms of displaying the form on any page:

    
    $formoptions = array(
      'post_title'      => true, // show the post title?
      'post_content'    => false, // show a body content editor?
      'post_id'         => $new_post, // this post should be new? or editing?
      'field_groups'    => array(256), // ID of the field group i want to show here
      'submit_value'    => 'Publish', // submit button text
      'return'          => get_permalink(142), // redirect URL
      'uploader'        => 'wp' // what type of uploader to use
    );
    acf_form($formoptions);
    

    It’s really quite simply and it’s all documented here.

    But more than that, these forums are here to help. So once you have your code almost there, come back and we can help you through the rest 🙂

  • @markbloomfield

    Hi, thanks for your reply. Ok,I’ve just purchased ACF Pro. And will open a new thread for this.

  • Hi @markbloomfield

    Already posted a new thread here.https://support.advancedcustomfields.com/forums/topic/acf-with-social-article/

    Could you please help me continue as you promise

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

The topic ‘Can ACF do this? (with Social Article)’ is closed to new replies.