Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 5,601 through 5,625 (of 32,505 total)
  • Author
    Search Results
  • 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?

    #180378

    Topic: PHP Warnings

    in forum Installation
    avalanche
    Participant

    I’m receiving a php warning when I go to http://scafra.org/
    Warning: ksort() expects parameter 1 to be array, object given in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php on line 316

    When I go to /wp-login.php I receive these warnings:
    Warning: ksort() expects parameter 1 to be array, object given in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php on line 316

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php:316) in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-login.php on line 394

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php:316) in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-login.php on line 407

    After I attempt to login, I receive an error that my password is incorrect, and then I receive these warnings:
    Warning: ksort() expects parameter 1 to be array, object given in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php on line 316

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php:316) in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-login.php on line 394

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php:316) in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-login.php on line 407

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php:316) in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-includes/pluggable.php on line 893

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php:316) in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-includes/pluggable.php on line 894

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-content/plugins/bbpress/includes/core/template-functions.php:316) in /home/content/p3pnexwpnas01_data01/45/3635545/html/wp-includes/pluggable.php on line 895

    Although I can’t login via WordPress, I can FTP, but I’m not sure what to change.

    #180373
    Sadegh Hosseini
    Participant

    Hi,
    Is there any plugin (or code) to create admin per forum that each admin can moderate only his forum and don’t have moderation tools for other forums.
    Thanks

    #180355
    Alex Stine
    Participant

    Hello,

    I have a custom user meta field which is a staff label field. For people with “staff” capability, they can go to their profile in WP admin and enter some text for a label such as “Lead Developer, Writer, Support, etc. I would like to output this label on BBPress profile but cannot figure out how to do it. I am using the currently displayed profile ID. In the following file:
    /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single/members-header.php

    I know it’s bad to hack core files, I will move to my themes folder once it’s working. This is the code I have currently.

    <?php
    $member_id = bp_displayed_user_id();
    if ( user_can( $member_id, 'staff' ) ) {
    if ( get_the_author_meta( 'staff') ) {
    $x = ( get_the_author_meta( 'staff', $member_id ) == '' ) ? "Staff" : get_the_author_meta( 'staff', $member_id );
    echo '<div class="staff-label">';
    echo $x ;
    echo '</div>';
    } 
    } ?>

    This code is working fine in the comments area with different logic to grab the user ID, just not working for BuddyPress. Any suggestions?

    Thanks. 🙂

    #180354
    oyegigi
    Participant

    In case someone wants to use the code who is using pretty links.

    
    // Generate BBporess Edit Profile Link in a shortcode
    // [bbp_edit_profile text="Edit My Profile" class"my-link-style"]
    
    function bbp_edit_profile_link($atts) {
    	extract(shortcode_atts(array(
    		'text' => "",  // default value if none supplied
    		'class' => "" //Style class for link
        ), $atts));
        
        if ($text) {
    		$current_user = wp_get_current_user (); 
    		$user=$current_user->user_login;
            return '<a class="'. $class . '" href="/forums/users/' . $user . '/edit">' . $text. '</a>';
            
        } 
    }
    add_shortcode('bbp_edit_profile', 'bbp_edit_profile_link');
    
    #180351
    King-Nothing
    Participant

    I totally forgot about this thread.

    I fixed it with css:

    nav .menu li a span {
    display: none;
    font-size: 10px;
    font-weight: 400;
    opacity: 0.6;
    }

    But I guess it would be better to edit some code instead?

    Url is: http://testsentralen.no/nyfotoblogg2/

    #180341
    grimbot
    Participant

    Hi, at the top of the pages of this forum, an error shows up. It says:

    Continue reading→” />

    This error would show up from time to time on user created pages when there was a format issue. To fix it there, I would just jiggle the code around until the error went away.

    The forum pages are not user created though so I’m not sure how to clear this error.

    #180338
    scotth454
    Participant

    I am getting mine started up an have spent most of my saturday with the same problem. action-modeler.com

    <li id="menu-item-1016" class="menu-item menu-item-type-post_type_archive menu-item-object-forum menu-item-1016"><a>All Forums<span class="menu-tag">bbPress Forums</span></a></li>

    menu manager

    Adding a second all forums menu doesn’t have the extra “bbPress Forums”.

    Well I figured out setting it as a page to get the all forums. Apparently using the all forums from the “Forums” in menu manager is bugged.

    #180334
    Barry
    Participant

    …A PHP 5.2-friendly version that also covers the reply and forum post types:

    function bbpress_enable_rest_api_support() {
    	$enable_rest = array( 'show_in_rest' => true );
    	register_post_type( bbp_get_reply_post_type(), $enable_rest );
    	register_post_type( bbp_get_topic_post_type(), $enable_rest );
    	register_post_type( bbp_get_forum_post_type(), $enable_rest );
    }
    
    add_action( 'bbp_register_post_types', 'bbpress_enable_rest_api_support', 11 );
    #180333
    Barry
    Participant

    To enable default REST API support for topics you could use a snippet like this one:

    add_action( 'bbp_register_post_types', function() {
    	register_post_type( bbp_get_topic_post_type(), [ 'show_in_rest' => true ] );
    }, 11 );

    This waits until bbPress has registered its post types, then modifies the properties of the topic post type so that it is exposed via the REST API. You could of course extend it to cover forum and reply posts, too. With that in place, you should find URLs like the following work as expected:

    http://bbpress.site/wp-json/wp/v2/topic

Viewing 25 results - 5,601 through 5,625 (of 32,505 total)
Skip to toolbar