Skip to:
Content
Pages
Categories
Search
Top
Bottom

add a link to discussion


  • michaelgoal
    Participant

    @michaelgoal

    Hi,
    I would like to add some content, a link, in the first created topic in a discussion. (just like this is the first in this discussion)

    This link should link to a page with an overview showing all the blogs that this specific user has created, that are related to the topic.
    I use this blog : https://www.buddyboss.com/product/buddypress-user-blog/

    So this link should only be visible if the user has created blogs related to this topic.

    Next step is to have a “Create_New_Post” link (only visible for the specific user) above
    the other link. This way i can relate this specific discussion to the blogs created.
    This link will link to the page where users can create a new post.

    I think this will find out if the specific user has created blogs :
    $ids = $wpdb->get_col( $wpdb->prepare( “SELECT id FROM $wpdb->posts WHERE post_author = $userid && post_type = topic && post_status = publish”, $term_id ) );
    But i have to add some request if these blog posts should be related to a specific discussion.

    If someone can give me ideas to make some function to do this, i will be very happy 🙂

    Michael

Viewing 6 replies - 1 through 6 (of 6 total)

  • Robin W
    Moderator

    @robin-w

    you would probably need to hook to

    apply_filters( ‘bbp_get_topic_content’, $content, $topic_id );

    after that beyond free help from me I’m afraid 🙁


    michaelgoal
    Participant

    @michaelgoal

    I found this. With this function im able to insert some content in the first reply.
    But this part dont work out, it just shows text and not which user id it is…:
    <a href=\create-new-post?vis=$current_user_id\
    How can i get a variable, here user_id, to create-new-post page ?
    I have tried with “$current_user_id ” and ‘$current_user_id’ …..

    function add_content_before_first_reply_content($content,$id){

    $post = get_post($id);
    $topic_id = bbp_get_topic_id();
    $reply_id = bbp_get_reply_id();
    $current_user_id = get_current_user_id();
    $content_to_add = ‘ Add new blog
      
    ‘;

    if ($topic_id === $reply_id) {
    // do whatever you need to in here
    $content .= $content_to_add;
    }

    return $content;

    }
    add_filter( ‘bbp_get_reply_content’, ‘add_content_before_first_reply_content’, 99, 2 );


    michaelgoal
    Participant

    @michaelgoal

    function is like this and not what i posted before:
    and my problem is this:
    ?vis=$current_user_id (you can see it if you are going to the link “Add new blog”)

    function add_content_before_first_reply_content($content,$id){
    
    	$post = get_post($id);
    	$topic_id = bbp_get_topic_id();
    	$reply_id = bbp_get_reply_id();
    	$current_user_id = get_current_user_id();
    	$content_to_add = '<a href="\create-new-post?vis=$current_user_id">&nbsp;Add new blog 
                              &nbsp;&nbsp;</a>';
    
    	if ($topic_id === $reply_id) {
    		
    		$content .= $content_to_add;
    	}
    
    	return $content;
    
    }
    add_filter( 'bbp_get_reply_content', 'add_content_before_first_reply_content', 99, 2 );

    michaelgoal
    Participant

    @michaelgoal

    I have this in my url:
    /create-new-post/?vis=current_user_id

    current_user_id should be userid as a number for logged in user.
    And i would like to bring Postid to create-new-post page too..

    Any ideas how it works in bbpress ?


    Robin W
    Moderator

    @robin-w

    $content_to_add = '<a href="\create-new-post?vis='.$current_user_id.'">Add new blog</a>';


    michaelgoal
    Participant

    @michaelgoal

    I have this now, but how do i assigm $kat_id to tthe Blog post category when i submit my Blogpost?

    function add_content_before_first_reply_content($content,$id){
    
    	$post = get_post($id);
    	$topic_id = bbp_get_topic_id();
    	$reply_id = bbp_get_reply_id();
    	
    	$hf_user = wp_get_current_user();
    	$hf_username = $hf_user->user_login;
    	
        $kat_id = wp_get_post_parent_id($post);
    	
    	
        $content_to_add =&quot;<a href=&quot;create-new-post?vis=$kat_id>&nbsp;Add new blog &nbsp;</a>
    	
    	if ($topic_id === $reply_id) {
    		// do whatever you need to in  here
    		$content .= $content_to_add;
    	}
    
    	return $content;
    
    }
    add_filter( 'bbp_get_reply_content', '
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar