Skip to:
Content
Pages
Categories
Search
Top
Bottom

Require tags for topics/replies + AJAX


  • zilveer
    Participant

    @zilveer

    Hello everyone,

    I would like to require tags for topics and replies. I managed to find some help.
    Here is the code which you can have in your functions.php file.

    
    /*
    @ Require tags for posting topics, replies
    */
    add_action( 'bbp_new_topic_pre_extras', 'check_front_end_tags_wpse_82956' );
    add_action( 'bbp_new_reply_pre_extras', 'check_front_end_tags_wpse_82956' );
    
    function check_front_end_tags_wpse_82956(){
    if( empty( $_POST['bbp_topic_tags'] ) )
    {
    // WORKAROUND FOR LINKS WITH HASH TAG, e.g., topic/lorem-ipsum#post-91
    // Necessary when posting multiple replies that generate hashed links
    // OTHERWISE A SIMPLE href="javascript:history.go(-1) WOULD WORK
    ?>
    function goBack() {
    if (window.history && history.pushState) {
    history.replaceState("", "", "?no-tags=true);
    history.go(-1);
    }
    }
    <?php
    
    wp_die( '<a href="history.go(-1)" rel="nofollow">' . __( '&laquo; &laquo; Please type at least one tag' ) . '</a>' );
    }
    }
    

    But I would like to use AJAX and a modal dialog for displaying the requirements when someone creates a topic or replies and forgets to type in a tag.
    How can I do this, can someone give me guidance here?

    regards

Viewing 1 replies (of 1 total)

  • evanevans333
    Participant

    @evanevans333

    Interested in a solution for this as well. I would like AJAX Tags, and Tags required. An existing plugin recommendation would be great, or if anyone wants to do some code mod, I’m game to test it out 😉

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar