Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 11,401 through 11,425 (of 32,506 total)
  • Author
    Search Results
  • Jerry
    Participant

    I have been working for about 5 days to get topics from a forum on one site to show on my main page, which is a separate site. I’m running current versions of wordpress multisite, bbpress, and buddypress on my main page.

    I found some code via my searches and created a simple plugin. It works to display topics from a separate site on my main page. That was a victory for sure. The problem I am now having is the formatting! Arrghh! I cannot get it to format correctly.

    I know that others have been wanting to do this, so perhaps someone else can get me to the final step and we can publish a good plugin. Here is the code:

    <?php
    /* 
    		Plugin Name: Recent bbpress Topics
    		Plugin URI: http://whosgotbooks.com/wp-content/plugins
    		Description: A plugin to display recent bbpress topics across the network
    		Version: 1.0.0
    		Author: Jerry Caldwell
    		Author URI: http://whosgotbooks.com
    		License: Open Source 
    */ 
    
    function recent_bbpress_topics_shortcode() {                  
      recent_bbpress_topics(); }
      add_shortcode( 'recent-bbpress-topics', 'recent_bbpress_topics_shortcode' );
    
    // ! // Add Recent Topics to BBPress
    function recent_bbpress_topics() {
      if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 8 ) ) ) { 
          //bbp_get_template_part( 'bbpress/loop', 'topics' );
          bbp_get_template_part( 'loop', 'topics' );
          }
    // Hook into action
    add_action('bbp_template_after_forums_loop','recent_bbpress_topics');
    
    } ?>

    I have been trying to get this to format with bbpress.css. I managed to changed the css on one of my sites to get things how I want, but I can’t with this function. Here is a link of how I want things to look: http://whosgotbooks.com/book-reviews/
    And here is the link of the main page, where I can’t quite get it the way I want it: http://whosgotbooks.com/

    Here is the bbpress.css that worked on the review page, but doesn’t work for the main page:

    li.bbp-topic-title {
    	float: left;
    	text-align: left;
      overflow: hidden;
    	width: 75%;
    }
    #bbpress-forums li.bbp-body ul.topic {
    /*	border-top: 1px solid #7D573A; */ 
      border-top: transparent;
    	overflow: hidden; 
      display: inline-table;  
    	padding: 8px;
      width: 22%;
    }

    To get the books somewhat organized on the main page, I had to change width to 20% on the bbp-topic-title class above, and the bbp-body ul.topic changes do not help on the main page.
    This is the extent of my abilities. I would love to get rid of those annoying dots as well. Hopefully someone can help me get the rest of the way.
    Thanks…

    #148823
    Robin W
    Moderator

    If you’ve cracked the code for the submenu, then groups are a buddypress thing, so their forum might be better.

    But from total ignorance try….

    If you’ve phpmyadmin access, you could set up a user for a group, and see what changes in the usermeta, and then use this to create your filter

    eg
    if say you found that buddypress_group was what was used for groups, you could set the group using

    $current_user = wp_get_current_user();
    $group=get_user_meta( $current_user , 'buddypress_group', true);
    

    then dependant on group

    if ($group==22) then...
    if ($group==23) then....
    
    #148821
    Robin W
    Moderator

    In essence if I understand it you want to change the

    reply/edit/merge/trash/close/trash/reply links that come up with a topic or reply so that only some show, and others are in a dropdown list.

    is that correct?

    if so then

    my goal with this is to call each admin link individually and make only 2 or 3 to be visible
    (reply,edit,maybe quote link from gd bbpress tools)

    simply requires you to filter for those you want to display

    open up

    bbpress/includes/replies/template.php

    and you’ll see the admin links function line starting at line 1811

    On lines 1840 to 1848 you’ll see the default links are added.

    So lets create a function to just have the first two

    you’ll see a filter in line 1841 (‘apply_filters’) and we can hook to that

    so

    //change admin links displayed
    function change_admin_links ($r) {
    $r['links'] = apply_filters( 'rw_reply_admin_links', array(
    				'edit'  => bbp_get_reply_edit_link ( $r ),
    				'move'  => bbp_get_reply_move_link ( $r )
    			), $r['id'] );
    return $r['links'] ;
    }
    add_filter ('bbp_reply_admin_links', 'change_admin_links' ) ;
    
    

    just leaves us with edit and move.

    This also gives you the ability to add a new link, with say your dropdown list.

    You’ll also see that this function checks if it is a topic on line 1825, and you’ll need to similarly create a function for that – I’ll leave you to work that one out.

    Come back if you need more help, and when you crack this, can you post the finished code to this site so we can see what it looks like.

    #148818
    Robin W
    Moderator

    no the file is one that belongs to your theme called just functions.php

    you’ll find it at

    wp-content/themes/%yourthemename%/functions.php

    where %yourthemename% is the name of your theme.

    If you don’t have a child theme, then you should create one, see

    Functions files and child themes – explained !

    #148812
    Robin W
    Moderator

    yes, drop this into your functions file.

    Functions files and child themes – explained !

    This will send users to the /forums/ page whenever they log out -whether private or public forum or on a topic or reply, or anywhere within bbpress. If you logout, you’re saying your done, so taking you back to the index seems a logical place to end up !

    You can change the $url to say ‘/home/’ if you want the home page,

    //sends the user to $url - in this case '/forums/'  
    function rw_logout ($redirect_to) {
    	$url='/forums/' ;
    	$redirect_to = '<a href="' . wp_logout_url( $url ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>' ;
    	return $redirect_to ;
    	}
    	
    	add_filter ('bbp_get_logout_link', 'rw_logout') ;
    	
    #148800
    Robin W
    Moderator

    It could be coded, but it’s not possible at the moment.

    My private groups plugin is probably the closest – it lets you assign users to forums, but as the name suggests keeps the forums private. http://www.rewweb.co.uk/bbp-private-groups/

    I don’t currently have plans to offer that possibility.

    #148779
    Sam Rohn
    Participant

    the separate bbpress dynamic caps have been very frustrating for me, i had actually been able to rig something up as the OP described a few years ago with user role editor plugin, but it was broken by the caps change in 2.2 🙁

    Roles and Capabilities in bbPress 2.2

    an interface to set granular permissions per forum by user or user role for bbpress would be a HUGE boon, this is a core feature of all other forum software i am aware of

    otherwise, here is an article on customizing bbpress dynamic caps, haven’t tried this one yet

    http://gawainlynch.com/customising-dynamic-roles-in-bbpress-2-2/

    i have seen robin’s new plugin too, might do almost what i need but i haven’t had a chance to test it yet, but ultimately my goal would be the ability to create different forums for different customized (custom code or URE etc) member roles which are auto-assigned by s2 member

    sam

    #148778

    In reply to: Forum Structure error

    Stephen Edgar
    Keymaster

    If you can’t change the slug to forum and it stays as forum-2 check the trash folder, the permalink won’t be released until the deleted item is removed from the trash 😉

    #148776
    davidslessmaccom
    Participant

    Hi,

    Looking at our error log, we get a recurrent error generated by bbpress which has led to 502 errors. We are using WordPress 3.9 and bbpress Version 2.5.4. would you please advise us on this:

    Thank you. http://communication.org.au

    The error log looks like this:
    [Sun Jul 06 00:49:32 2014] [error] [client 124.191.29.124] LONG QUERY (1540 characters long generated in /nas/wp/www/cluster-1417/davidsless/wp-content/plugins/bbpress/includes/users/functions.php:1531):

    
    SELECT 
    COUNT(NULLIF(meta_value LIKE '%"administrator"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"editor"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"author"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"contributor"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"subscriber"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"bbp\\_keymaster"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"bbp\\_spectator"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"bbp\\_blocked"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"bbp\\_moderator"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"bbp\\_participant"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"shop\\_accountant"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"shop\\_worker"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"shop\\_vendor"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"customer"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"shop\\_manager"%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level1″%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level2″%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level3″%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level4″%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level5″%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level6″%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level7″%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level8″%', false)), 
    COUNT(NULLIF(meta_value LIKE '%"s2member\\_level9″%', false)), 
    COUNT(*) 
    FROM wp_usermeta 
    WHERE meta_key = "wp_capabilities", referer:
    

    Communication Research Institute

    #148775
    Stephen Edgar
    Keymaster

    Uncheck the bbPress setting “Forum Prefix – Prefix all forum content with the Forum Root slug” will be as close as you get giving you mydomain.com/blog/forum/

    The thing here is bbPress is a WordPress plugin so it ‘runs under’ WordPress.

    I am quite sure with a few tweaks of how your WordPress install is configured (you might also need some .htaccess rewrite rules) I think you could achieve what you are looking for though.

    See the following link on where I would start, will take a bit of planning and backups or course

    https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

    #148761
    Robin W
    Moderator

    bbpress has a separate set of capabilities, so you can set permissions for the wordpress part of your site totally separately to the capabilities for bbpress.

    see

    https://codex.bbpress.org/bbpress-user-roles-and-capabilities/

    and if needbe

    Custom Capabilities

    Robin W
    Moderator

    long answer I’m afraid and in two parts

    part 1 – setting the user permission to allow delete topic and delete reply

    delete is easy, making it only trash is in part 2 !

    Basically you’ll need to change a couple of capabilities of the participant role

    see

    https://codex.bbpress.org/bbpress-user-roles-and-capabilities/

    you see the abilities delete topics and delete replies (as distinct from delete others topics and delete others replies)

    Whilst you could amend the participant role, I haven’t documented that, so easiest is just for you to create a new role and give it the participant capabilities plus the ‘delete topics’ and ‘delete replies’. This article explains how

    Custom Capabilities

    add this code to your functions file – see

    Functions files and child themes – explained !

    part 2 – changing the function, so that delete is only shown for keymasters

    This code will only allow a keymaster to permanently delete a topic

    add the following to your functions file

    add_filter ('bbp_get_topic_trash_link', 'topic_dont_delete');
    add_filter ('bbp_get_reply_trash_link', 'reply_dont_delete');
    
    function topic_dont_delete( $args = '') {
    
    		// Parse arguments against default values
    		$r = bbp_parse_args( $args, array(
    			'id'           => 0,
    			'link_before'  => '',
    			'link_after'   => '',
    			'sep'          => ' | ',
    			'trash_text'   => esc_html__( 'Trash',   'bbpress' ),
    			'restore_text' => esc_html__( 'Restore', 'bbpress' ),
    			'delete_text'  => esc_html__( 'Delete',  'bbpress' )
    		), 'get_topic_trash_link' );
    
    		$actions = array();
    		$topic   = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    
    		if ( empty( $topic ) || !current_user_can( 'delete_topic', $topic->ID ) ) {
    			return;
    		}
    
    		if ( bbp_is_topic_trash( $topic->ID ) ) {
    			$actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) ) . '" class="bbp-topic-restore-link">' . $r['restore_text'] . '</a>';
    		} elseif ( EMPTY_TRASH_DAYS ) {
    			$actions['trash']   = '<a title="' . esc_attr__( 'Move this item to the Trash',      'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash',   'topic_id' => $topic->ID ) ), 'trash-'   . $topic->post_type . '_' . $topic->ID ) ) . '" class="bbp-topic-trash-link">'   . $r['trash_text']   . '</a>';
    		}
    		
    		if ( bbp_is_topic_trash( $topic->ID ) || !EMPTY_TRASH_DAYS ) {
    		if ( bbp_is_user_keymaster()) {
    		$actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently',     'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete',  'topic_id' => $topic->ID ) ), 'delete-'  . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-topic-delete-link">' . $r['delete_text'] . '</a>';
    		}
    		}
    
    				// Process the admin links
    		$retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];
    
    		return $retval ;
    	}
    	
    	function reply_dont_delete( $args = '' ) {
    
    		// Parse arguments against default values
    		$r = bbp_parse_args( $args, array(
    			'id'           => 0,
    			'link_before'  => '',
    			'link_after'   => '',
    			'sep'          => ' | ',
    			'trash_text'   => esc_html__( 'Trash',   'bbpress' ),
    			'restore_text' => esc_html__( 'Restore', 'bbpress' ),
    			'delete_text'  => esc_html__( 'Delete',  'bbpress' )
    		), 'get_reply_trash_link' );
    
    		$actions = array();
    		$reply   = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
    
    		if ( empty( $reply ) || !current_user_can( 'delete_reply', $reply->ID ) ) {
    			return;
    		}
    
    		if ( bbp_is_reply_trash( $reply->ID ) ) {
    			$actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-restore-link">' . $r['restore_text'] . '</a>';
    		} elseif ( EMPTY_TRASH_DAYS ) {
    			$actions['trash']   = '<a title="' . esc_attr__( 'Move this item to the Trash',      'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'trash',   'reply_id' => $reply->ID ) ), 'trash-'   . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-trash-link">'   . $r['trash_text']   . '</a>';
    		}
    
    		if ( bbp_is_reply_trash( $reply->ID ) || !EMPTY_TRASH_DAYS ) {
    		if ( bbp_is_user_keymaster()) {
    		$actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently',     'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete',  'reply_id' => $reply->ID ) ), 'delete-'  . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-reply-delete-link">' . $r['delete_text'] . '</a>';
    		}
    		}
    
    		// Process the admin links
    		$retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];
    
    		return $retval ;
    	}
    

    I haven’t fully tested this code as my test site is in some disarray whilst I test something else, so you’ll need to check that it works

    #148736
    Robin W
    Moderator

    presume you removing the titles from

    wp-content/bbpress/templates/default/bbpress/loop-forums

    and renaming as per

    https://codex.bbpress.org/step-by-step-guide-to-setting-up-a-bbpress-forum-part-3/ section 3

    then

    wp-content/bbpress/templates/default/bbpress/loop-single-forum

    has the content that you’ll want to take out

    #148735
    sagive
    Participant

    i need to create a new top of user and want to give it “read=>true” capability only…

    example

    $cpar_capabilities = array(
        'read'	=> true
    )
    add_role('course_participant', 'Course Participant', $cpar_capabilities);

    would this mean he / she cant publish on the forums and if so how can i add the right capabilities so those user can participate in the forums but have read only permission
    or any type of other permissions on my site?

    #148727
    Stephen Edgar
    Keymaster

    Make a copy of your full width template, maybe page.php and rename it bbpress.php 🙂

    #148725
    Stephen Edgar
    Keymaster

    Yes, it should NOT go there, you should add it to your child themes functions.php file.

    Remove it from where you added it.

    See https://codex.wordpress.org/Child_Themes on creating a child theme.

    And this is where you add that code https://codex.wordpress.org/Child_Themes#Using_functions.php

    #148721
    Stephen Edgar
    Keymaster

    Thanks @lyhiz, indeed that plugin does add some a spoiler BBCode, thanks.

    #148719
    thecatholicwoman
    Participant

    Also I wanted to keep the update from no.2 but the new code changed the font color on the titles of the forums back to black but it did change the font. I am not sure if I was supposed ot change something.

    #148716
    Robin W
    Moderator

    hmmm.. ok but we’re starting to need lots of extra code

    ok so add

    #bbpress-forums a {
    color: #111111 !important ;
    }

    This will change the font throughout, and you can play with the colour.

    If you want the topic and date to be different, we’re getting into some real css styling, which is beyond the purpose of the bbpress support forum, and perhaps you need to start to look at how to use firebug so you can see what you need to change eg

    then you can style any forums part by preceding it with

    #bbpress-forums as I’ve done above.

    #148712
    Rescue Themes
    Participant

    Really old thread but sharing my solution in case it’s helpful for anyone else. I used:

    <?php single_post_title(); ?>

    Instead of:

    bbp_get_forum_title

    #148711
    Leonyipa
    Participant

    @netweb I tried but I cannot remove it, can you tell me which piece of code do I need to remove? Thanks 🙂

    #148708
    lyhiz
    Participant
    #148702
    Leonyipa
    Participant

    after putting the new code, it now says:

    Fatal error: Cannot redeclare ntwb_custom_topic_form_notice() (previously declared in /home/gleam/public_html/wp-content/plugins/bbpress/includes/core/functions.php:633) in /home/gleam/public_html/wp-content/plugins/bbpress/includes/core/functions.php on line 627

    I actually placed the code in bbpress/includes/core/functions.php
    is it wrong?

    #148695
    thecatholicwoman
    Participant

    I am not sure if this helps but when I select bbpress forum index template from the side menu for page templates it does not allow me to put in the side bar and runs full width but the text and coloring matches my theme. When I do it with the page builder in the divi theme and I use the [bbp-forum-index] short code in a text box element and then add a sidebar element on the side, I get the side bar but the forum does not match the theme because I have to use the default template. So it is almost like it is not pulling from the coding in the style.css at all so it may make sense that my altering that file does not change it.

    #148693
    Stephen Edgar
    Keymaster

    That’s weird, did you add it twice?
    Fatal error: Cannot redeclare ntwb_bbp_theme_before_topic_form_notices() (previously declared..

    It could be my hastily quick copy and paste job, here is the same thing with an alternate function name, make sure you remove the previos function. 😉

    
    function ntwb_custom_topic_form_notice() {
    	?>
    	<div class="bbp-template-notice">
    		<p>Something here...</p>
    		<p>Something else...</p>
    	</div>
    	<?php
    
    }
    add_action( 'bbp_theme_before_topic_form_notices', 'ntwb_custom_topic_form_notice' );
    
Viewing 25 results - 11,401 through 11,425 (of 32,506 total)
Skip to toolbar