• Resolved John

    (@artoftech)


    Hi, I’m using the Create Post form and I see you can add a tag(s) field, which can be singular or multiple choice. I also need to be able to have the user create new ones. I could add a repeater and have this capture tag input(s) but am not sure how to convert it/them to post tag(s)? Is this possible? Many thanks for this great plugin!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @artoftech,

    The Forminator forms are meant for simple actions, I’m afraid, at the moment there isn’t any out-of-the-box feature to create post tags and it’ll require custom coding.

    You could check whether using custom fields could help in such a workflow. You might find the following helpful using the ACF plugin:

    https://support.advancedcustomfields.com/forums/topic/add-post-tags-from-custom-fields-value/

    Kind Regards,

    Nithin

    Thread Starter John

    (@artoftech)

    Hi, I found an article about adding categories that makes use of the “forminator_post_data_field_post_saved”
    action.

    Here is the code I wrote to create tags from a custom field:

    add_action( ‘forminator_post_data_field_post_saved’, function( $post_id, $field, $data ) {
    if($field[“options”][1][“label”] === ‘custom_tags’) {
    $tags_val = $data[“post-custom”][1][“value”];
    wp_set_post_terms( $post_id, $terms = $tags_val, $taxonomy = ‘post_tag’, $append = false );
    }
    }, 99, 3);

    I am fairly new to WP PHP, and haven’t done any error trapping yet; so it probably isn’t super robust, but gives others a starting point if they are in need of this capability.

    BTW-I couldn’t find a list of actions like this in the docs. Can you point me to a resource if it exists?

    Thanks for your time and the excellent plugin!

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @artoftech

    At the moment I’m afraid we only have the following docs in terms of API:
    https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/

    Our team is already working on improving the documentation when it comes to hooks.

    Kind Regards,
    Kris

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add tags using Create Post’ is closed to new replies.