• Resolved johnh10

    (@johnh10)


    Hello, great plugin!

    Currently when USP calls wp_update_post, I have other code that triggers off the save_post hook and adds taxonomies based on the post content. When control returns to USP, it replaces those taxonomies with the user submitted taxonomies when I want them to append instead. So I changed

    wp_set_post_tags($post_id, $tags);
    wp_set_post_categories($post_id, $category);

    to

    wp_set_post_tags($post_id, $tags, true );
    wp_set_post_categories($post_id, $category, true );

    but it would be great if those 3rd function parameters (to append) was an option or at least put through a filter. Thanks for considering!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Absolutely, this is an excellent idea. Thank you @johnh10!

    Thread Starter johnh10

    (@johnh10)

    Excellent! Also would like to stress adding a filter for tags/categories, so I can use a code snippet to exclude certain terms. Filters are great to put in as you never know what a future user will want to do. ??

    Plugin Author Jeff Starr

    (@specialk)

    Just to follow up, the next version of USP includes new filter hooks, usp_append_tags and usp_append_cats, as described in your post.

    For this:

    “Also would like to stress adding a filter for tags/categories”

    If you let me know specifically where in the code these would be helpful, I will be glad to add them. Thank you, @johnh10.

    Thread Starter johnh10

    (@johnh10)

    That would be great!

    Specifically, in the file user-submitted-posts.php, in function usp_createPublicSubmission, right before the lines

                    wp_set_post_tags($post_id, $tags, true );   
    
                    wp_set_post_categories($post_id, $category);

    I’m using my own code lines that are:

                    $tags = apply_filters( 'usp_check_tags', $tags );
                    $category = apply_filters( 'usp_check_category', $category );

    Then my code snippets do the custom checks I want. I can change the filter name to whatever you come up with, of course.

    Plugin Author Jeff Starr

    (@specialk)

    Ok thanks, it shall be done next update. Cheers!

    Thread Starter johnh10

    (@johnh10)

    Thanks for adding the append filters! Appreciated.

    Any chance of the custom filters for tags/categories? So the user can run custom checks on the submitted taxonomies? In my case I make all tags lowercase and strip out hashtags.

    Plugin Author Jeff Starr

    (@specialk)

    You’re welcome, @johnh10.

    I’m happy to add any hooks, just let me know where you need them and it shall be done.

    Thread Starter johnh10

    (@johnh10)

    Hello, just the ones mentioned above, before the wp_set_post_tags/categories calls.

    They are something like

    $tags = apply_filters( 'usp_check_tags', $tags );
    $category = apply_filters( 'usp_check_category', $category );

    filter names can be anything. ‘usp_custom_user_tag_check’ instead of ‘usp_check_tags’ if that works better.

    Plugin Author Jeff Starr

    (@specialk)

    You got it, will add next update.

    Plugin Author Jeff Starr

    (@specialk)

    Just to follow up, two hooks added in the next/upcoming version of USP:

    usp_filter_tags
    usp_filter_cats

    These will filter the tags and categories as they are submitted. Next USP should be available today or sometime this weekend.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Request support for appending taxonomies’ is closed to new replies.