PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

User Selects Post Format

  1. Hey All -

    I see that I can choose a post format from the "Post Title" field, but I was wondering if this is something that a user can decide when submitting content? In the same respect, this will also allow me to show fields based on their selection. Thanks!

    Posted 12 years ago on Wednesday August 22, 2012 | Permalink
  2. I don't think it's possible to do that in the form builder automatically. However, you could have a group of radio buttons with your post formats as options, then use the gform_after_submission hook to go back and update the post format using the WordPress function set_post_format. http://codex.wordpress.org/Function_Reference/set_post_format

    You can follow this example:
    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    But instead of wp_update_post, you could use set_post_format, and set the format to the one the user selected from your radio buttons.

    The list of radio buttons would not be generated dynamically. I'm not sure how often the post formats you're using change, but that could be a potential problem, keeping your form and your installation in sync.

    If by this: "allow me to show fields based on their selection", you mean "if the user wants to create a post of the Photo format, then show fields to allow them to upload an image, submit a caption submit the location, etc" and "if the user wants to create a post of the Recipe format, then allow them to use the list field to add ingredients one by one, submit the directions, and allow up to 10 photos" ... the answer is yes. Just use conditional logic to allow the fields that pertain only to that post format.

    Does that help?

    Posted 12 years ago on Sunday August 26, 2012 | Permalink
  3. yeah that does help. I'll give it a shot this week, thanks!

    Posted 12 years ago on Sunday August 26, 2012 | Permalink
  4. Let us know how that works out.

    Posted 12 years ago on Sunday August 26, 2012 | Permalink
  5. so I gave it a shot, but seem to be missing something. I must be leaving something out:

    http://pastie.org/4619327

    Posted 12 years ago on Thursday August 30, 2012 | Permalink
  6. That doesn't look right at all. Can you explain what each line of your code is supposed to do? I think we have a fundamental misunderstanding here and we need to get on the same page. Thanks.

    Posted 12 years ago on Friday August 31, 2012 | Permalink
  7. Hey Sorry for the delayed response, and thanks for reaching back out. I will take some time to review my code and explain what I "thought" I was attempting.

    Posted 12 years ago on Wednesday September 5, 2012 | Permalink
  8. Hey Chris,

    I was missing the variables necessary to pass into new_post_format($entry,$form). This link works:

    http://pastie.org/4715557

    Posted 12 years ago on Thursday September 13, 2012 | Permalink
  9. Is this working for you now?

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  10. yes it is...thanks for the push in the right direction!

    Posted 12 years ago on Saturday September 15, 2012 | Permalink
  11. Great. Thanks very much for the update. I'm glad you figured it out.

    Posted 12 years ago on Saturday September 15, 2012 | Permalink

This topic has been resolved and has been closed to new replies.