Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create/add forum from frontend


  • inderpreet2018
    Participant

    @inderpreet2018

    Hi ,

    I am using Divi theme, buddypress for user profile and bbpress for forum.

    I want to add forum for forntend “moderator” user, where they can create/start new forum. Like users can create New Topic.

    I used some code to add forum for forntend, but that’s not worked, as code is for bbpress only.
    2018-10-14_1905

    I already asked bbpress regardinng the issue. They said, as I used buddypress and buddypress profile, asked buddypress for help. https://www.screencast.com/t/89AvqQwHVC

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

  • Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    In place of current_user_can(‘moderate’) please use bb_current_user_can(‘moderate’)

    Thanks


    inderpreet2018
    Participant

    @inderpreet2018

    I replaced current_user_can(‘moderate’) to bb_current_user_can(‘moderate’), but nothing works and gives error on my forum page
    2018-10-16_0729
    2018-10-16_0730


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    Please go with current_user_can. I found that in a link on bbpress I think but that function is no more there.


    inderpreet2018
    Participant

    @inderpreet2018

    Hi,

    I used “current_user_can” function, but Forum form is not displaying for moderators.


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    Please use this code:

    add_action('bbp_template_after_user_details', 'ps_show_forum_form');
    
    function ps_show_forum_form(){
    	if(bbp_is_user_home() && current_user_can('moderate')){
    		echo do_shortcode('[bbp-forum-form]');
    	}
    }

    It will echo a form on the profile itself.

    Thanks


    inderpreet2018
    Participant

    @inderpreet2018

    Hi,

    I used the above code as you said. But the same, nothing is showing up
    2018-10-18_0757


    Prashant Singh
    Participant

    @prashantvatsh

    Ok, got it now.

    The above code will show the forum form on bbpress user profile, not BuddyPress.

    Please try this code:

    add_action('bbp_template_after_user_topics_created', 'ps_show_forum_form');
    
    function ps_show_forum_form(){
    	if(bbp_is_user_home() && current_user_can('moderate')){
    		echo do_shortcode('[bbp-forum-form]');
    	}
    }

    Thanks


    inderpreet2018
    Participant

    @inderpreet2018

    Thanks Parshant, finally something is worked. Above code works and shows under Topics Started tab.
    2018-10-20_2006

    Is there any way to show Forum Form as tab like Topic started and other tabs?


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    Please replace the previous code with this code if you want a tab and not the previous one:

    function ps_profile_forum_creation() {
    	if(current_user_can('moderate')){
    		global $bp;
          	bp_core_new_subnav_item( array( 
                'name' => 'Create Forum', 
                'slug' => 'create-forum', 
                'screen_function' => 'ps_create_forum_screen', 
                'position' => 200,
                'parent_url'      => bp_loggedin_user_domain() . '/forums/',
                'parent_slug'     => 'forums',
                'default_subnav_slug' => 'create-forum'
          	) );
    	}
    }
    add_action( 'bp_setup_nav', 'ps_profile_forum_creation' );
     
     
    function ps_create_forum_screen() {
        add_action( 'bp_template_content', 'ps_create_forum_screen_content' );
        bp_core_load_template( 'buddypress/members/single/plugins' );
    }
    
    function ps_create_forum_screen_content() {
        echo do_shortcode('[bbp-forum-form]');
    }

    Hopefully, it will help you.
    Thanks


    inderpreet2018
    Participant

    @inderpreet2018

    Wow! it worked.

    Thanks for your help.


    Prashant Singh
    Participant

    @prashantvatsh

    Glad to know that it helped you 🙂


    olufemishield
    Participant

    @olufemishield

    @prashantvatsh thank you for this. My case is a little different. I want to a tab in the buddypress profile menu that shows all the site-wide forums where members can click and add topics or replies. They wont be able to create forum. Basically, I just need what I see in “homepage/forums” to be replicated in homepage/members/username/forums.

    Thanks in advance


    Rajeshkumar Samani
    Participant

    @rsamani61

    Thank you so much for your useful helping code.


    edensan
    Participant

    @edensan

    Wow sounds good!! What file do i have to place?

    Greetz Edwin from Holland

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