Home Forums Plugin Support WP User Frontend (Free Version) User can add taxonomy

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  Tareq Hasan 6 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3312

    ced
    Participant
    Post count: 32

    Hi,
    Is it possible to let users add a taxonomy after having selected a parent taxonomy ?
    I mean, I have taxonomies as country -> state.
    After selected a state, if city doesn't already exist as taxonomy, then add it to the form with a “Insert your city” button.

    #3317

    Tareq Hasan
    Keymaster
    Post count: 2831

    Sorry, thats not possible with the builtin plugin functionality. You've to build this functionality on your own with the help of documentation.

    #3318

    ced
    Participant
    Post count: 32

    Do you mean using a html field or action hook ?

    Edit. Sorry never mind. Thought your link was the link to the main doc. Can you give more information on the action hook .

    #3321

    Tareq Hasan
    Keymaster
    Post count: 2831

    The action hook field already gives some information about how to work with action hooks.
    [php]
    add_action(‘HOOK_NAME', ‘your_function_name', 10, 3 );
    function your_function_name( $form_id, $post_id, $form_settings ) {
    // do what ever you want
    }
    [/php]

    So the approach you've to take is:
    1) Show a category dropdown in this function.
    2) Handle the onchange event of the dropdown and send ajax request
    3) Check if there aren't any states for that country and send response
    4) Handle the response and show/hide input field for new state
    5) Upon submitting the form, use the wpuf_add_post_after_insert hook to create a taxonomy entry and attach to the post id. Example:

    [php]
    function wpufe_create_tax( $post_id ) {

    if ( isset( $_POST[‘your_tax_name_input'] ) ) {
    // create your taxnomy and attach to the post id
    }
    }

    add_action( ‘wpuf_add_post_after_insert', ‘wpufe_create_tax' );
    add_action( ‘wpuf_edit_post_after_update', ‘wpufe_create_tax' );
    [/php]

    Thats all I can help.

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

The topic ‘User can add taxonomy’ is closed to new replies.