Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 11,601 through 11,625 (of 32,504 total)
  • Author
    Search Results
  • #147816
    Robin W
    Moderator

    Ok, what I want to do is check if the function is trying to filter and failing or not even trying to filter.

    I am therefore going to get the plugin to dump one of the lists, so that you can tell me what it is showing – it won’t look pretty, but should help.

    First of all you need to work out a search that produces only a few results, say less than 10, and that you can list all the results that you would expect to see for full access, and that you want to see for the private groups, and make a not of their numbers.

    so for instance

    search for zebra produces posts numbers

    2345,2367,2657,2894,2965

    But one of these is in a private forum so a non-logged in user should see

    2345,2367,2894,2965

    Once you have this list, then do the following :
    Use notepad to create a file called search.php

    then put this code into it

    <?php
    
    //this function filters to the bbp search function to allow only returns from allowed forums
    
    function pg_has_search_results( $args = '' ) {
    	global $wp_rewrite;
    //start with code as per bbp search !
    	/** Defaults **************************************************************/
    
    	$default_post_type = array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    
    	// Default query args
    	$default = array(
    		'post_type'           => $default_post_type,         // Forums, topics, and replies
    		'posts_per_page'      => bbp_get_replies_per_page(), // This many
    		'paged'               => bbp_get_paged(),            // On this page
    		'orderby'             => 'date',                     // Sorted by date
    		'order'               => 'DESC',                     // Most recent first
    		'ignore_sticky_posts' => true,                       // Stickies not supported
    		's'                   => bbp_get_search_terms(),     // This is a search
    	);
    
    	// What are the default allowed statuses (based on user caps)
    	if ( bbp_get_view_all() ) {
    
    		// Default view=all statuses
    		$post_statuses = array(
    			bbp_get_public_status_id(),
    			bbp_get_closed_status_id(),
    			bbp_get_spam_status_id(),
    			bbp_get_trash_status_id()
    		);
    
    		// Add support for private status
    		if ( current_user_can( 'read_private_topics' ) ) {
    			$post_statuses[] = bbp_get_private_status_id();
    		}
    
    		// Join post statuses together
    		$default['post_status'] = implode( ',', $post_statuses );
    
    	// Lean on the 'perm' query var value of 'readable' to provide statuses
    	} else {
    		$default['perm'] = 'readable';
    	}
    	
    	//PG then loop to find allowable forums
    	//Get an array of IDs which the current user has permissions to view
    	$allowed_posts = private_groups_get_permitted_post_ids(new WP_Query($default));
    	Echo 'Allowed posts list' ;
    	var_dump ($allowed_posts) ;
    	// The default forum query with allowed forum ids array added
        $default['post__in'] = $allowed_posts;
    
        
    	//then return to bbp search code
    	/** Setup *****************************************************************/
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, $default, 'has_search_results' );
    
    	// Get bbPress
    	$bbp = bbpress();
    
    	// Call the query
    	if ( ! empty( $r['s'] ) ) {
    		$bbp->search_query = new WP_Query( $r );
    	}
    
    	// Add pagination values to query object
    	$bbp->search_query->posts_per_page = $r['posts_per_page'];
    	$bbp->search_query->paged          = $r['paged'];
    
    	// Never home, regardless of what parse_query says
    	$bbp->search_query->is_home        = false;
    
    	// Only add pagination is query returned results
    	if ( ! empty( $bbp->search_query->found_posts ) && ! empty( $bbp->search_query->posts_per_page ) ) {
    
    		// Array of arguments to add after pagination links
    		$add_args = array();
    
    		// If pretty permalinks are enabled, make our pagination pretty
    		if ( $wp_rewrite->using_permalinks() ) {
    
    			// Shortcode territory
    			if ( is_page() || is_single() ) {
    				$base = trailingslashit( get_permalink() );
    
    			// Default search location
    			} else {
    				$base = trailingslashit( bbp_get_search_results_url() );
    			}
    
    			// Add pagination base
    			$base = $base . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
    
    		// Unpretty permalinks
    		} else {
    			$base = add_query_arg( 'paged', '%#%' );
    		}
    
    		// Add args
    		if ( bbp_get_view_all() ) {
    			$add_args['view'] = 'all';
    		}
    
    		// Add pagination to query object
    		$bbp->search_query->pagination_links = paginate_links(
    			apply_filters( 'bbp_search_results_pagination', array(
    				'base'      => $base,
    				'format'    => '',
    				'total'     => ceil( (int) $bbp->search_query->found_posts / (int) $r['posts_per_page'] ),
    				'current'   => (int) $bbp->search_query->paged,
    				'prev_text' => is_rtl() ? '&rarr;' : '&larr;',
    				'next_text' => is_rtl() ? '&larr;' : '&rarr;',
    				'mid_size'  => 1,
    				'add_args'  => $add_args, 
    			) )
    		);
    
    		// Remove first page from pagination
    		if ( $wp_rewrite->using_permalinks() ) {
    			$bbp->search_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->search_query->pagination_links );
    		} else {
    			$bbp->search_query->pagination_links = str_replace( '&paged=1', '', $bbp->search_query->pagination_links );
    		}
    	}
    	//finally filter to return
    	// Return object
    	return apply_filters( 'pg_has_search_results', $bbp->search_query->have_posts(), $bbp->search_query );
    }
    
    add_filter ('bbp_has_search_results', 'pg_has_search_results') ; 

    Then go into FTP

    Then look in

    wp-content/plugins/bbp-private-groups/includes

    and you’ll see a file called

    wp-content/plugins/bbp-private-groups/includes/search.php

    Rename this file to searchold.php (as we’ll need it back later!)

    Then copy the search.php that you made above to this folder (wp-content/plugins/bbp-private-groups/includes).

    Then run your search.

    You should see a horrible list at the start, but this will be what should be the filtered list

    run this with full access and with restricted access (ie not logged in) and tell me what lists you get and of they are different.

    #147815
    Robin W
    Moderator

    That is quite complicated.

    However this will add ‘edit profile’ to you menu if you put it in your function file !

    // Filter wp_nav_menu() to add profile link
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
    function my_nav_menu_profile_link($menu) { 	
    	if (is_user_logged_in()) {
    		$current_user = wp_get_current_user();
    		$user=$current_user->user_login ;
    		//Lower case everything
    		$user = strtolower($user);
    		//Make alphanumeric (removes all other characters)
    		$user = preg_replace("/[^a-z0-9_\s-]/", "", $user);
    		//Clean up multiple dashes or whitespaces
    		$user = preg_replace("/[\s-]+/", " ", $user);
    		//Convert whitespaces and underscore to dash
    		$user = preg_replace("/[\s_]/", "-", $user);
    		$profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
    		$menu = $menu . $profilelink;
    		return $menu;
    	
    }
    #147806
    Robkk
    Moderator

    use css to make your changes

    Step by step guide to setting up a bbPress forum – part 2

    everything is pretty much in there

    #147793
    Robin W
    Moderator
    Robin W
    Moderator

    Really glad that writing that part of the guide has worked for someone else – it was a real challenge to write !

    Try changing the line

    add_filter( 'bbp_get_topic_reply_link','jc_return_review' );

    to

    add_filter( 'bbp_before_get_topic_reply_link_parse_args','jc_return_review' );
    

    This lets you change just one part of the function.

    #147787

    In reply to: Full Width Forum Help

    Robin W
    Moderator

    ok, this is not my strong area, but try making this as your bbpress.php page

    
    <?php 
    
    get_header(); // Loads the header.php template. ?>
     
    	<?php if ( is_bbpress() ) { ?>
     
    		<header class="entry-header">
    			<h1 class="entry-title"><?php single_post_title(); ?></h1>
    			<?php echo apply_atomic_shortcode( 'entry_byline', '<div class="entry-byline">' . __( 'Published by [entry-author] on [entry-published] [entry-comments-link before=" | "] [entry-edit-link before=" | "]', 'spine2' ) . '</div>' ); ?>
    		</header><!-- .entry-header -->
     
    		<?php while( have_posts() ): the_post(); ?>
     
    			<?php the_content(); ?>
     
    		<?php endwhile; ?>
     
     
    		<footer class="entry-footer">
    			<?php echo apply_atomic_shortcode( 'entry_meta', '<div class="entry-meta">' . __( '[entry-terms before="Posted in " taxonomy="category"] [entry-terms before="| Tagged "]', 'spine2' ) . '</div>' ); ?>
    		</footer><!-- .entry-footer -->
     
    	<?php } else { ?>
    	<div id="content" class="hfeed">
     
    		<?php get_template_part( 'loop-meta' ); // Loads the loop-meta.php template. ?>
     
    		<?php get_template_part( 'loop' ); // Loads the loop.php template. ?>
     
    		<?php get_template_part( 'loop-nav' ); // Loads the loop-nav.php template. ?>
     
    	</div><!-- #content -->
     
    <?php get_footer(); // Loads the footer.php template. ?>
    Jerry
    Participant

    I have read the following explanation on using filters, and have become somewhat proficient on this. http://codex.bbpress.org/step-by-step-guide-to-setting-up-a-bbpress-forum-part-5/

    I am having an issue, to which I believe there is probably a simple answer. I want to replace the word “Reply” with “Review This Book” in the admin links. Easy enough. But when I do that, there is no longer a link; I want to maintain the same link.

    According to the tutorial I have been using (above link), I am supposed to use a function like this:

    function jc_return_review( $args = array() ) {
     $args['reply_text'] = 'Review This Book';
     return $args;
    }

    Then I implement the following:
    add_filter( 'bbp_get_topic_reply_link','jc_return_review' );

    However, the above function causes the following error:
    “Warning: Illegal string offset ‘reply_text’ in /homepages/../../../../wp-content/plugins/bp-custom.php on line 111
    Ra href=”#new-post” class=”bbp-topic-reply-link”>Reply”

    But…, when using the following function

    function jc_return_review() {
    return 'Review This Book';
    }

    And the same filter above, the wording gets replaced just fine, but as I mentioned at the start of this post, there is no longer a link. In other words, without my filter, REPLY is a link that takes you to the reply window. When using my filter, Review This Book is present, but there is no link associated with Review This Book.

    Thanks for any help here.

    #147769
    wallyhood
    Participant

    Something is broken with my use of BBPress related to jQuery:

    Using the jQuery selector does not work. For example:

    $(".title")
    TypeError: undefined is not a function
    

    However, using
    jQuery(".title")

    does work. This is breaking other plugins and code I have on my site (http://www.wallyhood.org). I’ve tried disabling all other plugins except for BBPress, and the problem still occurs. I’ve tried enabling all plugins EXCEPT BBPress and the problem doesn’t occur. So it would seem that it must be BBPress causing the issue, except that I would assume lots of other people would be reporting it if that were the case.

    Any help?

    #147736
    Steve Truman
    Participant

    Hi Guys

    A conflict exists with bbPress and the WooSidebars plugin

    The conflict causes the whole forum to return a 503 Error. After much digging found the problem comes from this bbPress function

    bbp_get_topic_title() function

    and is fixed by changing

    $title = get_the_title( $topic_id )

    to

    $topic = get_post( $topic_id );
    $title = $topic->post_title;

    Hope you can add that fix to your next version update – Thank you – Steve

    #147731
    Giacomo
    Participant

    An easy way to achieve the second option would be to copy paste this code at the end of the file named functions.php in your current theme folder.

    Make sure to create a backup of the file functions.php first. And always do the changes on a test server, not the live one.

    
    function rsb_limit_posting( $retval ) {
    
    	// count topics of the current user
    	$topic_count = bbp_get_user_topic_count_raw( get_current_user_id() );
    	// if they are 10 or more, do not allow him to create new topic
    	if ( $topic_count > 9 ) return false;
    	// otherwise return the default 
    	return $retval;
    
    }
    add_filter( 'bbp_current_user_can_access_create_topic_form', 'rsb_limit_posting' );
    

    The code above hide the “new topic form” for users who posted 10 or more topics.

    Hope it helps… good luck!

    #147719
    NewSha
    Participant

    I want the users to get email alerts every time their forum role changes.

    Namely, I want to notify users only if their role has changed to Participant.

    I found a way to do this with standard WordPress roles, but it doesn’t work with bbPress roles.

    http://clicknathan.com/web-design/notify-a-wordpress-user-when-their-role-has-been-changed-to-a-specific-role/

    I tried changing if ($new_role == 'contributor') to if ($new_role == 'participant') and even to this if ($new_role == 'bbp_participant') – nothing worked.

    WordPress version: 3.8.2
    bbPress version: 2.5.3

    #147697

    In reply to: Full Width Forum Help

    Robin W
    Moderator

    try taking out the three lines

    <div class=”aside”>
    
    <?php get_sidebar( ‘primary’ ); // Loads the sidebar-primary.php template. ?>
    
    </div>
    

    That div class is probably creating a space for the sidebar

    #147689
    Seedsoms
    Participant

    The profile edit page seems to be broken. When I view it all I see is

    Profile Topics Started Replies Created Favorites Subscriptions Edit Name Name First Name Last Name Nickname Display Name Seedsoms Contact Info Contact Info Website About Yourself About Yourself Biographical Info Account […]

    I assume I’m supposed to be able to edit a lot of these values, such as “Edit Name” or “About Yourself” but it’s all just static text. The […] you see above is linked, but linked back to the profile edit page I am already on.

    #147687

    In reply to: Full Width Forum Help

    watstyl08
    Participant

    Thanks for your response! I’ve done that – and it takes the sidebar away, but no luck on getting bbpress to go full-width.

    At least with that small modification to my bbpress.php, I know bbPress is pointed to the right template — now I just need to figure out what code is preventing the full-width format.

    Link to my forum:

    http://www.ibeacon.com/forums/

    #147686

    In reply to: Full Width Forum Help

    Robin W
    Moderator

    I’d take out the line

    <?php get_sidebar( ‘primary’ ); // Loads the sidebar-primary.php template. ?>

    as that is loading a sidebar !

    #147685
    watstyl08
    Participant

    Hey everyone,

    I’m having a bit of trouble getting my Forum into full-width format. I’m using the Oxygen theme which by default has a left and right sidebar.

    I’ve already copied my “page-template-fullwidth.php”, renamed it as “bbpress.php”, and installed bbPress WP Tweaks to make sure that bbPress is injecting itself into the “bbpress.php” template.

    Given what I’ve read – this should’ve done the trick. I’m wondering if it’s something weird with Oxygen Theme’s templates. I’ve included the code of the Full Width Template i’m using here below. Does anyone see anything out of the ordinary that could be preventing me from getting full-width formatting?

    <?php
    /**
    * Template Name: Full Width
    *
    * Full width page template with no sidebar.
    *
    * @package Oxygen
    * @subpackage Template
    */

    get_header(); // Loads the header.php template. ?>

    <div class=”aside”>

    <?php get_sidebar( ‘primary’ ); // Loads the sidebar-primary.php template. ?>

    </div>

    <?php do_atomic( ‘before_content’ ); // oxygen_before_content ?>

    <div class=”content-wrap”>

    <div id=”content”>

    <?php do_atomic( ‘open_content’ ); // oxygen_open_content ?>

    <div class=”hfeed”>

    <?php if ( have_posts() ) : ?>

    <?php while ( have_posts() ) : the_post(); ?>

    <?php do_atomic( ‘before_entry’ ); // oxygen_before_entry ?>

    <div id=”post-<?php the_ID(); ?>” class=”<?php hybrid_entry_class(); ?>”>

    <?php do_atomic( ‘open_entry’ ); // oxygen_open_entry ?>

    <?php echo apply_atomic_shortcode( ‘entry_title’, ‘[entry-title permalink=”0″]’ ); ?>

    <div class=”entry-content”>

    <?php the_content( __( ‘Continue reading <span class=”meta-nav”>→</span>’, ‘oxygen’ ) ); ?>

    <?php wp_link_pages( array( ‘before’ => ‘<p class=”page-links”>’ . __( ‘Pages:’, ‘oxygen’ ), ‘after’ => ‘</p>’ ) ); ?>

    </div><!– .entry-content –>

    <?php echo apply_atomic_shortcode( ‘entry_meta’, ‘<div class=”entry-meta”>[entry-edit-link]</div>’ ); ?>

    <?php do_atomic( ‘close_entry’ ); // oxygen_close_entry ?>

    </div><!– .hentry –>

    <?php do_atomic( ‘after_entry’ ); // oxygen_after_entry ?>

    <?php do_atomic( ‘after_singular’ ); // oxygen_after_singular ?>

    <?php endwhile; ?>

    <?php endif; ?>

    </div><!– .hfeed –>

    <?php do_atomic( ‘close_content’ ); // oxygen_close_content ?>

    </div><!– #content –>

    <?php do_atomic( ‘after_content’ ); // oxygen_after_content ?>

    <?php get_footer(); // Loads the footer.php template. ?>

    #147684
    Robin W
    Moderator

    the following code in your function file will remove the subscribe

    function remove_subscribe () {
    $retval=false ;
    return $retval ;
    }
    
    add_filter( 'bbp_get_topic_subscribe_link', 'remove_subscribe' );

    ‘share’ is a buddypress function I suspect – sorry I know nothing of buddypress !

    #147677
    Robin W
    Moderator

    There are all sorts of backdoors that a ‘page/post’ restricting plugin doesn’t cover for bbpress

    For instance :

    search is usually forum wide
    http://www.mysite.com/topics
    http://www.mysite.com/replies
    looking at topics/replies created in a user profile
    recent topics widget
    recent replies widget

    all usually just bypass a plugin written for pages.

    which is why I wrote the private groups plugin

    https://wordpress.org/plugins/bbp-private-groups/

    There is no reason why it shouldn’t work alongside your members with members protecting your pages & posts, and private groups protecting your forums.

    BUT you do have to set users up to see restricted forums, and this is manual. It is quick to do (just a setting within the user settings), but if you have an automated joining process, then you would need to add a manual step (or write some code!)

    #147676
    Robin W
    Moderator

    If it is text within wordpress/bbpess then the following code in you functions file will change it

    //This function changes the text wherever it is quoted
    function change_translate_text( $translated_text ) {
    	if ( $translated_text == 'old text' ) {
    	$translated_text = 'new text';
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'change_translate_text', 20 );
    

    But ‘text’ may be made up of code. For instance in your ‘create new topic in’ – the word topic may actually be a variable (I haven’t looked !), and the wrap around text used elsewhere for instance ‘create topic in’, ‘create reply in’, ‘create forum in’

    Daniel Tara
    Participant

    On my local server search results URLs get pretty permalinks and search works. On my live server the query string is shown and no search results are returned.

    I did a test by manually entering the search URL as it was prettyfied on my local server and surprisingly search works.

    The search URL that bbPress returns looks like this and returns no results:
    http://www.onedesigns.com/support/search?action=bbp-search-request&bbp_search=pinboard

    The prettified link for the same search looks like this:
    http://www.onedesigns.com/support/search/pinboard

    So the search engine works and apparently it’s the permalinks that cause the issue. Changing or resaving WordPress’ permalink setting didn’t make any difference.

    A var_dump for bbp_search returns NULL.

    The only difference between my local server and live server is that on my local server I use Apache and on my live serve nginx + Varnish.

    Is there any incompatibility between bbPress and nginx or Varnish? Are there any permalink configurations I must apply?

    Thank you

    #147671
    Killerrabbit2
    Participant

    WP V. 3.9.1
    bbPress v 2.5.4

    I’ve been banging my head against the wall on this one.

    Here is what I need to do:

    I have users who need to register for different forums. Each specific forum has restrictions. I am using the S2Member plugin. I can with their shortcodes restrict content within a page. I then can restrict a forum listing when I use a bbPress short code within a page.

    The problem is that bbPress dynamically creates topic pages, thus I can not put any shortcode logic in to restrict who sees the topics.

    S2Member has some code that works to restrict content with a function. However, using bbPress conditional tags don’t work. I can use the native conditional tags which do.

    Below is my code that I can’t seem to get working:

    add_action ("wp", "my_custom_capabilities");
    
    function my_custom_capabilities ()
    	{
    	if(bbp_is_topic_tag('Global'))
    		{
    		header ("Location: ".S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
    		exit();
    		}
    	}

    Ideas?!

    #147662
    sniffertje
    Participant

    I installed BBpress on wordpress, but when using HTML tags then these are not working.
    They are also not white or anything, it’s totally not in the post. Bold, Italic etc are working fine.

    For example which code is not working:

    #147650

    In reply to: Latest 5 Topics?

    Robin W
    Moderator

    I’ve just started working on a plugin that will have some additional shortcodes in it

    the only functional one so far is the ability to show the latest xx topics

    you can download it from here

    bbp additional shortcodes

    you use the shortcode

    [bbp_display_topic_index show=’5′]

    #147645
    annakyn
    Participant

    I would like to display the latest 5 topics, exactly as displayed on the homepage of bbpress. How do I go about this, I can’t seem to see a shortcode that would work?

    #147635
    Robin W
    Moderator

    and the second problem…

    the logon widget is held in :

    wp-content>plugins>bbpress>includes>common>widgets.php

    I suspect you’ll already know that it is bad practice to alter core files, as they get overwritten on upgrades.

    You’d do better to fork the code into your functions file, rename and create your own widget based on that.

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