Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 4,101 through 4,125 (of 32,517 total)
  • Author
    Search Results
  • #195602
    Robin W
    Moderator

    ok, I presume you meant this code

    //code to add tutor role 
     
    function add_new_roles( $bbp_roles )
    {
        /* Add a role called tutor */
        $bbp_roles['bbp_tutor'] = array(
            'name' => 'Tutor',
            'capabilities' => custom_capabilities( 'bbp_tutor' )
            );
     
        return $bbp_roles;
    }
     
    add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );
     
    function add_role_caps_filter( $caps, $role )
    {
        /* Only filter for roles we are interested in! */
        if( $role == 'bbp_tutor' )
            $caps = custom_capabilities( $role );
     
        return $caps;
    }
     
    add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
     
    function custom_capabilities( $role )
    {
        switch ( $role )
        {
     
            /* Capabilities for 'tutor' role */
            case 'bbp_tutor':
                return array(
                    // Primary caps
                    'spectate'              => true,
                    'participate'           => true,
                    'moderate'              => false,
                    'throttle'              => false,
                    'view_trash'            => false,
     
                    // Forum caps
                    'publish_forums'        => false,
                    'edit_forums'           => false,
                    'edit_others_forums'    => false,
                    'delete_forums'         => false,
                    'delete_others_forums'  => false,
                    'read_private_forums'   => true,
                    'read_hidden_forums'    => false,
     
                    // Topic caps
                    'publish_topics'        => true,
                    'edit_topics'           => true,
                    'edit_others_topics'    => false,
                    'delete_topics'         => false,
                    'delete_others_topics'  => false,
                    'read_private_topics'   => true,
     
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => false,
                    'delete_replies'        => false,
                    'delete_others_replies' => false,
                    'read_private_replies'  => true,
     
                    // Topic tag caps
                    'manage_topic_tags'     => false,
                    'edit_topic_tags'       => false,
                    'delete_topic_tags'     => false,
                    'assign_topic_tags'     => true,
                );
     
                break;
     
            default :
                return $role;
        }
    }

    so with that code loaded to my site, if I go to

    dashboard>users>all users and edit a user, I can change them to the tutor role, and back again and it saves.

    Can you confirm you are using the above code, and that it does not save if you perform the above ?

    #195600

    I added a link to a private forum in the menu so that a logged in user could easily access the forum. Yes I could add a menu for logged in users, but I decided to instead redirect the not logged in users.

    Here is the code I used:

    // Redirect private bbPress forum to specific page.
    add_action('template_redirect', 'private_content_redirect_to_login', 9);
    function private_content_redirect_to_login() {
      global $wp_query,$wpdb;
      if (is_404()) {
        $host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
        $path = dirname($_SERVER['REQUEST_URI']);
        $forums = "forum";
        $location = "https://direitoshumanosangola.org/not-logged-in/";
        }
        if(strpos( $path, $forums ) !== false){
          wp_safe_redirect($location);
          exit;
      }
    }

    I made a tutorial for it here:
    https://www.easywebdesigntutorials.com/hide-buddypress-pages-and-bbpress-forums-from-not-logged-in-users/

    #195582
    Robin W
    Moderator

    @looimaster I’m just a bbpress user trying to put something back on the open software community

    bbpress has https://bbpress.trac.wordpress.org/ as it’s code improvement tool

    #195556
    ak08820
    Participant

    I found another way to add forums to the menu at DesignBombs which seems to do it. Instead of creating a page and embedding the short code in it, just used the forums to add to the menu. It does not initially have the top level page with 4 sub forums but that is OK.

    #195539
    ak08820
    Participant

    Hello
    I am trying to use bbPress for a forum and when I use the short code to generate the index it does not show correctly. It does show a link (http://localhost/my-app/wordpress/forums/forum/wvv-forums/)for the index and if I click on the link it shows a better formatted list.

    I have 4 sub-forums and instead of 1 per line, it shows 2 per line. Using Twenty Seventeen and have previewed with sixteen and fifteen themes, too with no effect.

    What do I need to do to fix this?

    Thanks in advance.

    #195538
    jotirmoy7
    Participant

    hi,
    I create a new forum site with bbpress and BuddyPress.to fillup all forum category I copy paste posts from another. When I copy and paste post in the new topic by visual edit option and publish it some off content comes with HTML code.how to solve this. here I give two pics for you.

    View post on imgur.com

    <script async src=”//s.imgur.com/min/embed.js” charset=”utf-8″></script>
    after publishing the articles its show like this.

    View post on imgur.com

    <script async src=”//s.imgur.com/min/embed.js” charset=”utf-8″></script>

    plz, give me a solution to this problem. thank you.

    #195526
    Mal
    Participant

    Wow, thank you for your quick reply, I didn’t expect that there will be one 🙂

    I’m using v2.6 RC-6 and this doesn’t update the freshness. v2.6 has the same bug sadly.

    And when I go to Tools > Forums and run all “Recalculate…” tasks then ['bbp-forum-index'] shortcode loses sub-forums display on my front page of website. To fix this I have to go to “Forums” and open every parent forum and click “Publish” again.

    #195522
    Robin W
    Moderator

    Try this – or much easier just add my style pack plugin to your site which has this fix built in, and let me know if it fixes

    bbp style pack

    //filter to correctly return last active ID for sub forums
    //note : a parent forum or category can get the wrong last active ID if a topic in a sub forum is marked as spam or deleted. This filter ignores the parent and works out the correct sub forum
    
    //don't add if pg filter exists as this will have done it already
    if (!function_exists ('private_groups_get_permitted_subforums')) {
    	add_filter ('bbp_get_forum_last_active_id' , 'rew_get_forum_last_active_id', 10 , 2 ) ;
    }
    
    function rew_get_forum_last_active_id ($active_id, $forum_id) {
    	$sub_forums = bbp_forum_get_subforums($forum_id) ;
    	if ( !empty( $sub_forums ) ) {
    		$active_id = 0;
    		$show = array();
    		//find the latest permissible 
    		foreach ( $sub_forums as $sub_forum ) {
    			$sub_forum_id =  $sub_forum->ID ;
    			$active_id = get_post_meta( $sub_forum_id , '_bbp_last_active_id', true );
    			$last_active = get_post_meta( $sub_forum_id, '_bbp_last_active_time', true );
    			if ( empty( $active_id ) ) { // not replies, maybe topics ?
    				$active_id = bbp_get_forum_last_topic_id( $sub_forum_id );
    				if ( !empty( $active_id ) ) {
    					$last_active = bbp_get_topic_last_active_time( $active_id );
    				}
    			}
    			if ( !empty( $active_id ) ) {
    				$curdate = strtotime($last_active);
    				$show[$curdate] = $active_id ;
    			}
    		}
    		//then add the forum itself in case it has the latest
    			$active_id = get_post_meta( $forum_id , '_bbp_last_active_id', true );
    			$last_active = get_post_meta( $sub_forum_id, '_bbp_last_active_time', true );
    			if ( empty( $active_id ) ) { // not replies, maybe topics ?
    				$active_id = bbp_get_forum_last_topic_id( $forum_id );
    				if ( !empty( $active_id ) ) {
    					$last_active = bbp_get_topic_last_active_time( $active_id );
    				}
    			}
    			if ( !empty( $active_id ) ) {
    				$curdate = strtotime($last_active);
    				$show[$curdate] = $active_id ;
    			}
    		$mostRecent= 0;
    		foreach($show as $date=>$value){
    			if ($date > $mostRecent) {
    				 $mostRecent = $date;
    			}
    		}
    		if ($mostRecent != 0) {
    			$active_id = $show[$mostRecent] ;
    		} else {
    			$active_id = 0;
    		}
    	}
    	return apply_filters( 'rew_get_forum_last_active_id', $active_id, $forum_id );
    }
    #195505
    Leandro
    Participant

    Hello,

    Recently I started to setup a community using buddypress and bbpress and only after a few tests I noticed that when someone create or reply a topic no notification is created. This is a bit frustrating considering how important the notifications are to keep track of what is happening in the community.

    Looking through the forum for a solution I found a topic with a similar subject, however when trying to use their code a empty notification is created (there is no text or description). Here is the topic: https://bbpress.org/forums/topic/new-reply-notification-link-to-the-reply/

    Anyone can tell me if the code above still working? I think that something changed since that this code was published, but I cant figured out what.

    #195503
    inderpreet2018
    Participant

    Hi,

    I added forum form to the frontend with the help of shortcode “[bbp-forum-form]” to forum page. But when I submit forum, it will not saved and redirected me to other saved forum.

    When I created sub-forum then it works fine.

    eigodeasobo
    Participant

    Hi,All.

    Is there a way to specify multiple tag IDs when display topics?

    It’s a common-sense way of thinking↓

    <?php echo do_shortcode('[bbp-single-tag id=777,111]'); ?>

    But this code did not work 🙁

    I wonder what I should do.

    Thanks.

    #195497
    eigodeasobo
    Participant

    Hi,
    Unfortunately, it didn’t work out.

    add_action( 'bbp_new_reply_post_extras', 'rew_close_topic' );
    
    function rew_close_topic ($reply_id) {
    //  find out the topic_id
    $topic_id = bbp_get_reply_topic_id ($reply_id) ;
    $count = bbp_get_topic_reply_count ($topic_id) ;
    if ($count >9) bbp_close_topic( $topic_id );
    }

    If you have further information, please let me know.
    Thanks.

    #195495
    Robin W
    Moderator

    the screenshot says that you are using buddypress and the buddypress profile as well, and that code is just for bbpress.

    If you paste your reply immediately above on the buddypress support site, someone should be able to tell you the correct add_action to hook to buddypress profile

    https://buddypress.org/support/

    #195492
    inderpreet2018
    Participant

    I used above code as you said. But I don’t get any forum form on my profile
    2018-10-14_1902

    Screenshot for code
    2018-10-14_1905

    #195489
    Robin W
    Moderator

    the issue is with the ‘ the code has been copied via another program and is using the wrong ones

    copy this below

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

    the form is shown on the moderators profile

    #195485
    inderpreet2018
    Participant

    Hi,

    I used below code to add forum from frontend for Moderator user in my child-theme function file, but nothing works and showed on frontend.

    function ntwb_bbp_forum_form() {
    if ( bbp_is_user_home() && current_user_can( ‘moderate’ ) ) {
    echo do_shortcode( ‘[bbp-forum-form]‘ );
    }
    }
    add_action( ‘bbp_template_after_user_profile’, ‘ntwb_bbp_forum_form’ );

    Please help me to sort out this.

    #195480

    In reply to: Struggling with login

    Robin W
    Moderator

    ok, so using bbp-style pack (so make sure it is activated)

    In

    dashboard>settings>bbp Style pack>login

    set both

    Login menu item css class and
    Logout menu item css class 

    to

    aad

    then go to

    dashboard>settings>bbp Style pack>custom css and put this in there

    .aad {
    	margin-top: 11.9px;
    }

    if that doesn’t work, leave the code in there and come back

    #195474
    ankylol
    Participant

    Hello,

    Robin i added the tutor code to my functions file.As you can see in this link –> https://prnt.sc/l5mmhh i can see the role while editing users forum role.But the thing is when i try to give the user that Tutor role and save user profile.The forum role of the user is being -No roles for this forums- so i can’t give the custom role. Also i tried the other custom name functions thing.I created a role and gived it participant perms but couldn’t give that role to user too.

    #195470

    In reply to: Custom Topic Statuses?

    This will be easier to do in bbPress 2.6. A bunch of hooks were added to the codebase to make status manipulation possible in many ways it was not previously.

    #195460
    Robin W
    Moderator

    @clivesmith

    If you fine with code, then this is how I would go about it

    1. create a split in topic & replies, so you have a place to put the ‘featured reply’
    Use this piece of code in your functions file

    bbp_show_lead_topic

    2. then you’ll need a flag for the featured reply.

    This code does an ‘advert’ flag for a topic, but has much of the code you’d need to do a flag for a reply to show it is featured – I’ll leave you to work out which bits you’ll need, but the key is the hook to

    add_action( 'bbp_theme_before_topic_form_submit_wrapper', 'at_checkbox' );

    change this to

    add_action( 'bbp_theme_before_reply_form_submit_wrapper', 'at_checkbox' );

    amend the references from topic to reply

    and add some if(bbp_keymaster() ) to make it only show for you, and you will be most of the way there

    // show the "Mark if it is an advert" checkbox on topic form
    	add_action( 'bbp_theme_before_topic_form_submit_wrapper', 'at_checkbox' );
    		
    function at_checkbox() {
        // Text for the topic form
    	global $topic_advert_text ;
    	?>
    		<p>
    
    			<input name="at_advert" id="at_advert" type="checkbox"<?php checked( '1', at_is_advert( bbp_get_topic_id() ) ); ?> value="1" tabindex="<?php bbp_tab_index(); ?>" />
    
    			<?php if ( bbp_is_topic_edit() && ( get_the_author_meta( 'ID' ) != bbp_get_current_user_id() ) ) : ?>
    
    				<label for="at_advert"><?php echo '<span class="dashicons dashicons-awards"></span>'.$topic_advert_text.'</label>' ;?>
    
    			<?php else : ?>
    
    				<label for="at_advert"><?php echo '<span class="dashicons dashicons-awards"></span>'.$topic_advert_text.'</label>' ;?>
    
    			<?php endif; ?>
    
    		</p>
    <?php
    }
    	
    //check if topic is advert
    function at_is_advert( $topic_id = 0 ) {
    	
    	$retval 	= false;
    
    	if ( ! empty( $topic_id ) ) {
    		$retval = get_post_meta( $topic_id, 'at_topic_is_advert', true );
    	}
    	return (bool) apply_filters( 'at_is_advert', (bool) $retval, $topic_id );
    }
    
    // save the advert state
    		add_action( 'bbp_new_topic',  'at_update_topic' );
    		add_action( 'bbp_edit_topic',  'at_update_topic' );
    
    //update topic 
    function at_update_topic( $topic_id = 0 ) {
    
    		if( isset( $_POST['at_advert'] ) )
    			update_post_meta( $topic_id, 'at_topic_is_advert', '1' );
    		else
    			delete_post_meta( $topic_id, 'at_topic_is_advert' );
    
    	}

    3. amend content-single-topic-lead.php in your child theme’s bbpress directory.

    by

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    find
    wp-content/plugins/bbpress/templates/default/bbpress/content-single-topic-lead.php
    Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/content-single-topic-lead.phpbbPress will now use this template instead of the original and you can amend this

    This then you can use to add some code

    if (at_is_advert( $reply_id )) then….. display this reply

    and you should be there

    so

    the reply form will show a checkbox to make a reply featured available only to say keymaster, and as keymaster you can edit a topic to make it a featured
    the content_single_topic_lead will check if a reply is featured and then show it if it is

    I wish I had the time to code this all for you, but please if you do work oyt some code, post back here for other to benefit

    #195445
    Sociality
    Participant

    Hi there I had the same problem and I used this solution that does not use buddypress. The sanitize title I use if for greek so I do not post it here but you should use something for sure.

    //This is used to hide the username from the profile url
    function tpp_forum_profile_url( $user_id, $old_values) {
    	$user = get_user_by( 'ID', $user_id );	
    		$display_name = $user->data->display_name;	
    	if ( $user ) {
    		if ( $user->data->user_status == 0 && $display_name ) {
    			$new_user_nicename = tpp_sanitize_title($display_name );
    			if ( strlen ( $new_user_nicename ) > 50 ) {
    				$new_user_nicename = substr ( $new_user_nicename, 0, 50 );
    			}				
    			if ( $user->data->user_nicename != $new_user_nicename ) { 
    				$args = array(
    					'ID'            => $user->ID,
    					'user_nicename' => $new_user_nicename
    				);
    				wp_update_user( $args );
    				wp_redirect( get_site_url().'/forums/user/'.$new_user_nicename.'/edit/' ); 
    				exit;					
    			}
    		}
    	}
    }
    add_action( 'profile_update',  'tpp_forum_profile_url', 100, 5 );
    #195442

    In reply to: Custom Topic Statuses?

    Robin W
    Moderator

    bbpress does not do custom topic statuses, so they are coming from that support plugin, best post there as it is that plugin that needs to work with 2.6, but most plugin authors do not code for pre-release software as it changes.

    #195441
    Robin W
    Moderator

    ok, I cannot say why it is not working, it works in my test site

    I presume this code is going into you child theme’s function’s file – sorry but I do not know how technical you are, so I ask the obvious questions !

    you could try >9 and see if that works !

    #195440
    eigodeasobo
    Participant

    I changed that number from 100 to 10 and posted over 11 replies.

    if ($count == 100) bbp_close_topic( $topic_id );

    if ($count == 10) bbp_close_topic( $topic_id );

    However, it was not closed.

    Thanks.

    #195438
    Robin W
    Moderator

    that code will close the topic on 100 replies, so unless you tested with creating the 100th reply, then it would not work. Did you do this ?

Viewing 25 results - 4,101 through 4,125 (of 32,517 total)
Skip to toolbar