Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 5,626 through 5,650 (of 32,577 total)
  • Author
    Search Results
  • #180487

    I think I understand the expectation here, but that isn’t how it’s currently designed to work.

    More specifically, bbPress subscriptions do not discriminate against the user’s current role. If they were subscribed before, they’ll be subscribed until they unsubscribe.

    To achieve the behavior you desire, a plugin could be written that either:

    • Filters bbp_topic_subscription_user_ids and removes users with/out desired roles
    • Filter bbp_set_user_role and permanently delete all subscriptions when the new role matches one that qualifies

    Maybe a combination of both of the above, if you need to account for already removed users, but want to clean-up future role changes.

    Robin W
    Moderator

    ok, so

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

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

    find
    wp-content/plugins/bbpress/templates/default/bbpress/form-reply.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/form-reply.php
    bbPress will now use this template instead of the original
    and you can amend this

    so amend this file – copy it to your Pc and use norepad or similar

    around line 70 you will see

    <?php if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags' ) ) : ?>

    replace this with

    <?php
    	$user_id = wp_get_current_user()->ID;
    	$topic_id = bbp_get_topic_id() ;
    	$topic_author = bbp_get_topic_author_id( $topic_id ) ;
    	$is_topic_author = ($topic_author == $user_id ? true : false) ;
    	if ( bbp_allow_topic_tags() && current_user_can('assign_topic_tags' ) && ($is_topic_author || bbp_is_user_keymaster() ) : ?>

    This is untested, and if it doesn’t work – do come back !

    #180471
    consultant1027
    Participant

    This codex article is quite comprehensive about how to fight SPAM. (https://codex.bbpress.org/getting-started/forum-moderation/dealing-with-spam/)

    However, although it acknowledges profile SPAM, it fails amongst the many solutions to actually identify a method that is targeted at battling profile SPAM. You could switch to manual registration approval (which would be a pain in any moderate to high traffic site), but that would not solve the problem since the approved user can still post links in their profile.

    Akismet, WangGuard, etc, appear to only work on post/comment spam, not on profile spam, no?

    I don’t even have discussions enabled or commenting enabled so I don’t even care about post/comment spam!

    So as far as I can tell there is no plug-in or feature that will prevent profile SPAM. Someone please tell me I’m wrong!

    #180470
    Robin W
    Moderator

    untested, but this should do it, come back if not

    change line 3 to

    if ( is_user_logged_in() && is_bbpress() ) {

    and line 6 to

    elseif ( !is_user_logged_in() && is_bbpress() ) {

    #180469

    In reply to: Background Color

    Robin W
    Moderator

    your theme is re-writing the classes used by bbpress.

    Put this into the custom css – either of your theme if it has a custom css area, or into the custom css tab in my style pack plugin settings

    .x-bbp-search-form {
        background-color: #ffffff !important;
        }
    
    .bbp-forums ul, li {
    background-color: #ffffff !important;
    }
    #180466
    Sadegh Hosseini
    Participant

    Hi and thanks for your quick answer.
    I have child theme and I can copy bbpress theme inside it.
    I’d be thankful if you tell me how can I use these codes.
    Please consider that I want to let Keymaster and topic owner to edit topic tags.

    #180464
    haddlyapis
    Participant

    Hi,
    you provide code to add login and logout links on bbpress layout and functionality, which is just what i need.
    Question: Is there any way for it to only appear in my forum http://www.apis.de/forum (and all sub urls) but not on the rest of my site?

    #180462
    mth75
    Participant

    Quick solution but not really what i’m looking for (i’m looking to add a function as a real menu option).

    I order to add a Like option to the BBPress header menu in topics and replies I resorted to this quick solution (not perfect yet):

     <span class="bbp-admin-links">
    		<?php echo get_fav_or_unfav_button_for_bpp(); ?>
     </span>

    Add after <?php bbp_reply_admin_links(); ?> in loop-single-reply.php

    More info: https://bbpress.org/forums/topic/integrating-buddypress-favorite-system-aka-like-system-with-bbpress/

    mth75
    Participant

    I order to add a Like option to the BBPress header menu in topics and replies I resorted to this quick solution (not perfect yet):

     <span class="bbp-admin-links">
    		<?php echo get_fav_or_unfav_button_for_bpp(); ?>
     </span>

    Add after <?php bbp_reply_admin_links(); ?> in loop-single-reply.php

    But mission accomplished, the integration of the Buddypress Favorite system with BBPress is complete.

    Buddpress/BBpress Favorites integrated

    mth75
    Participant

    Solved:

    function get_fav_or_unfav_button_for_bpp( $reply ) {
    global $bp, $activities_template;
            // user is not logged ? Show nothing.
    	if ( ! is_user_logged_in() ) {
    	return '';
    	}
    	
    	$activity_id = (int) get_post_meta( bbp_get_reply_id( $reply_id ), '_bbp_activity_id', true ); 
    	
    	if ( ! $activity_id ) {
    	return '';
    	}
    	
    		bp_has_activities(); // update $activities_template of user's fav
    		$old_value = false;
    		
    		if ( isset( $activities_template->activity->id ) ) {
    		$old_value = $activities_template->activity->id;
    		$activities_template->activity->id = $activity_id;
    		} else {
    		$activities_template->activity = (object) array( 'id' => $activity_id );
    		}
    	
    		// building the template
    	$code = '';
    	$code .= '<div class="activity-like-count">'."\n";
    
    		if ( ! bp_get_activity_is_favorite() ) {
    		// if not favorited, add a fav button
    		$code .= ' <a href="'.bp_get_activity_favorite_link( ).'" class="acomment-like fav-comment bp-secondary-action" title="'.__( 'Like', 'buddypress' ).'">'.__( 'Like', 'buddyboss' ).'</a>'."\n";
    		
    		} else {
    		
    		// if already favorited, a button to unfav
    		$code .= ' <a href="'.bp_get_activity_unfavorite_link( ).'" class="acomment-like unfav-comment bp-secondary-action" title="'.__( 'Unlike', 'buddypress' ).'">'.__( 'Unlike', 'buddyboss' ).'</a>'."\n";
    		
    		}
    		
    		// closing .activity-meta
    	$code .= '</div>'."\n"; 
    
    		if ( false !== $old_value ) {
    		$activities_template->activity->id = $old_value;
    		} else {
    		$activities_template->activity = null;
    		}
    	return $code;
    	
    }
    
    ?>

    Add to loop-single-reply.php for BBPress:

    <?php echo get_fav_or_unfav_button_for_post( reply ); ?> or in the bbp_reply_menu, which i’m still trying to figure out:

    add my own menu option to the bbp-reply-header

    #180448
    Barry
    Participant

    Apologies all and good catch, Robin!

    I don’t think there’s anything wrong with your version of the code, but for the sake of alternatives here’s a fix for what I posted originally:

    function bbpress_enable_rest_api() {
    	$types = array(
    		bbp_get_reply_post_type(),
    		bbp_get_forum_post_type(),
    		bbp_get_topic_post_type(),
    	);
    
    	foreach ( $types as $slug ) {
    		$definition = (array) get_post_type_object( $slug );
    		$definition['show_in_rest'] = true;
    		$definition['rest_controller_class'] = 'WP_REST_Posts_Controller';
    		register_post_type( $slug, $definition );
    	}
    }
    
    add_action( 'bbp_register_post_types', 'bbpress_enable_rest_api', 11 );

    Beyond that, the links you shared (in terms of mixing in extra info such as the author’s details) look solid to me ๐Ÿ™‚

    Robin W
    Moderator

    ok, I’ve just loaded your code to my test site, and I can set a user to member and it holds

    Suspect either theme or other plugins

    bbPress is tested with wordpress default themes. It maybe a conflict – you need to check plugins and themes

    It could be a theme or plugin issue

    Plugins

    Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.

    Themes

    If plugins don’t pinpoint the problem, as a test switch to a default theme such as twentyfifteen, and see if this fixes.

    Then come back

    Robin W
    Moderator

    you would need to know how to copy a bbpress template, modify it and then load it to your child theme

    so you would need FTP access to your site

    If that sound possible, the come back and I’ll try to help further

    posting this untested code in here just so I don’t lose it !

    <?php
    					$user_id = wp_get_current_user()->ID;
    					$topic_id = bbp_get_topic_id() ;
    					$topic_author = bbp_get_topic_author_id( $topic_id ) ;
    					$is_topic_author = ($topic_author == $user_id ? true : false) ;
    					if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags' ) && $is_topic_author ) : ?>
    
    #180437
    Robin W
    Moderator

    Shortcodes

    [bbp-topic-form] โ€“ Display the โ€˜New Topicโ€™ form where you can choose from a drop down menu the forum that this topic is to be associated with.
    [bbp-topic-form forum_id=$forum_id] โ€“ Display the โ€˜New Topic Formโ€™ for a specific forum ID.

    Robin W
    Moderator

    ok, I can’t immediately see an error in your coding

    two thoughts

    1. does professional stick – I know you don’t want to use that, but it would help show if it is the whole code or just part that is not working.

    2. since lots of people copy code, it may be that your function names are not unique – eg function add_new_roles may exist elsewhere.

    Try making them unique

    ie change

    function add_new_roles

    to

    function kajzh_add_new_roles

    and change then filter that calls that function

    add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );

    to

    add_filter( 'bbp_get_dynamic_roles', 'kajzh_add_new_roles', 1 );

    and do this for all the functions – each has a name and then a filter that calls it.

    #180427
    Wilbur
    Participant

    Hi Robin and Barry, thanks for the help so far, it is working now. Though I have noticed that the API is not as robust as I expected it to be. For example the /reply endpoint doesn’t show the details of of the person who posted the reply (author) and moreover, say I wanted to view all the replies for a particular topic; can this be done?

    #180426
    soundboy
    Participant

    Hi, I’ve been working on migrating my large Drupal site to WordPress. I’ve managed to do the majority of the site but now I’m stuck on the forum.

    I’m using Drupal 6 and Advanced Forum, I have 26K topics and 700K replies.

    I’ve tried running the script on a couple of different local machines, and on my VPS server where I’ve had the most success; the script does the 26K topics smoothly but then hangs pretty early in the replies, around the 700th row. Locally, it gets stuck before. Weird thing is that a couple of times I’ve left it running for longer, eventually it manages to go past that sticking point and just continues extremely slowly.

    Also: I’ve read the troubleshooting instructions, which make sense but I don’t understand how to pinpoint the line numbers within the database, specifically these points:

    • “Now drop all the rows in the database that are not in the range of rows that failed during import”
    • “Once you have your list of offenders and the import has finished delete these rows from the database and test again to make sure it completes without hanging

    So question #1: if I look at my database in phpMyAdmin for example, and I know the problem is in rows 700-799 of my replies, how do I locate these rows?

    Question #2: Is there a way to know for sure if the problem is performance/memory related or if it’s an encoding issue in a specific row? I don’t know if I should be directing my efforts to solving performance issues or pinpointing problem rows.

    And finally question #3: Does anybody here have experience with these issues and would be willing to be hired to do this migration? Contact me if you do please!

    Thank you very much for any help you can provide ๐Ÿ™‚

    #180410
    TheDream18
    Participant

    Thanks Robin, Code worked

    #180409
    TheDream18
    Participant

    Yes. I used this code as topic that i did not get any support, only there alone topic active. If count voice =1 , will display [No support] to user know that noone in help theme issued yet.

    #180408
    Robin W
    Moderator

    the code for if… needs two = signs so try

    function none_people_discuss() {
    $voice_count = bbp_get_topic_voice_count(); 
    if ( $voice_count == 1 )
    echo '<span class=โ€no_supportโ€>[No support]</span>';
    }
    add_action( 'bbp_theme_before_topic_title', 'none_people_discuss' );
    #180406
    Robin W
    Moderator

    that code should put [no_support] before the topic title – is this what you are trying to achieve?

    #180403
    TheDream18
    Participant

    Hello,

    I used this code for clear Topic info. To show topic is not supported yet, only creater topic voices in current. I checked code was correct, but it did not work, anyone can help please?

    function none_people_discuss() {
    $voice_count = bbp_get_topic_voice_count();

    if ( $voice_count = 1 )
    echo ‘<span class=”no_support”>[No support]</span>’;
    }

    add_action( ‘bbp_theme_before_topic_title’, ‘ none_people_discuss’ );

    kajzh
    Participant

    Hello,

    I am running bbPress v2.5.12 on WordPress 4.7 with a child theme I’ve developed based on Imaginem Themes’ Sentric Theme.

    The problem:
    In my child theme’s functions, I have added the following code to make two custom roles, Professional and Member, for my Q&A/”Ask the Expert”-style forum called “Ask a Professional.” Essentially, Members can make threads asking questions, but only screened Professionals have the ability to reply and provide answers.

    I want everyone to automatically be assigned the Member role upon registration. Then I can manually “upgrade” their roles to Professional once they’ve been successfully screened. However, when a user registers and logs in, they inherit Member capabilities, but are not assigned the Member role. Manually selecting the user and assigning them the Member role doesn’t work; their role immediately reverts back to “โ€” No role for these forums โ€””
    screenshot

    When I select the user and manually assign the Participant role, the role “sticks” โ€” meaning, it doesn’t revert back to “No Role.” However, the “Member” capabilities remain.

    screenshot

    Does anyone know why this problem persists and how to fix it? This is the final thing that needs to be ironed out before my site goes live. ๐Ÿ™‚ Thank you!

    //code to add custom roles 
     
    function add_new_roles( $bbp_roles )
    {
        /* Add a role called professional */
        $bbp_roles['bbp_professional'] = array(
            'name' => 'Professional',
            'capabilities' => custom_capabilities( 'bbp_professional' )
            );
     
        /* Add a role called member */
        $bbp_roles['bbp_member'] = array(
            'name' => 'Member',
            'capabilities' => custom_capabilities( 'bbp_member' )
            );
     
        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_professional' )
            $caps = custom_capabilities( $role );
     
        if( $role == 'bbp_member' )
            $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 'professional' role */
            case 'bbp_professional':
                return array(
                     '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'    => true,
     
                    // Topic caps
                    'publish_topics'        => true,
                    'edit_topics'           => true,
                    'edit_others_topics'    => false,
                    'delete_topics'         => true,
                    'delete_others_topics'  => true,
                    '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'     => true,
                    'edit_topic_tags'       => true,
                    'delete_topic_tags'     => true,
                    'assign_topic_tags'     => true,
                );
     
                /* Capabilities for 'member' role */
            case 'bbp_member':
                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'       => false,
                    'edit_replies'          => false,
                    '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'     => false,
                );
     
                break;
     
            default :
                return $role;
        }
    }

    Troubleshooting:

    1. I’ve tried to disable plugins and see if any of them are causing this issue. This hasn’t yielded any different results.
    2. I’ve checked with the Twenty Sixteen and Twenty Seventeen theme.
    #180384
    Robin W
    Moderator

    quickest way is to add this to your .css file

    .bbp-topic-started-by {
      display: none;
    }
    #180383
    Robin W
    Moderator

    I found that the above code took away the Forums, Topics and Replies from the dashboard in bbpress.

    I found some other code and modified it as follows

    /**
      * Add REST API support to an already registered post type.
      */
      add_action( 'init', 'rew_custom_post_type_rest_support', 25 );
      
      function rew_custom_post_type_rest_support() {
      	global $wp_post_types;
      
      	$post_type_name =  bbp_get_reply_post_type();
      	if( isset( $wp_post_types[ $post_type_name ] ) ) {
      		$wp_post_types[$post_type_name]->show_in_rest = true;
      		$wp_post_types[$post_type_name]->rest_base = $post_type_name;
      		$wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
      	}
    	$post_type_name =  bbp_get_topic_post_type();
      	if( isset( $wp_post_types[ $post_type_name ] ) ) {
      		$wp_post_types[$post_type_name]->show_in_rest = true;
      		$wp_post_types[$post_type_name]->rest_base = $post_type_name;
      		$wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
      	}
    	$post_type_name =  bbp_get_forum_post_type();
      	if( isset( $wp_post_types[ $post_type_name ] ) ) {
      		$wp_post_types[$post_type_name]->show_in_rest = true;
      		$wp_post_types[$post_type_name]->rest_base = $post_type_name;
      		$wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
      	}
    	  
      }

    @barryhughes-1 – thoughts – can this be done better?

Viewing 25 results - 5,626 through 5,650 (of 32,577 total)
Skip to toolbar