Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 2,876 through 2,900 (of 32,453 total)
  • Author
    Search Results
  • #210236
    Robin W
    Moderator

    @clivesmith – had a think about guest posters – we can’t show the post, as by definition they are not logged in, so unless you show all moderation replies to all users (which defeats the purpose of moderation 🙂 ) they won’t see the post.

    bbpress doesn’t have the functionality that chuckie shows for topics above.

    I’ll try and see if I can work some code as I dig further into this, but no promises 🙂

    #210229
    Robin W
    Moderator

    I’ve had a play this evening with this issue.

    This code is very rough and ready, but if it works as I think it does, then it shows pending REPLIES to the user who posted them and moderators and keymasters. NOT topics !!

    so when a user posts a reply and it goes into moderation, they see there reply in the topic with a warning.

    If you want to try it, put this in your child theme’s function file – or use

    Code Snippets

    add_filter ('bbp_has_replies' , 'rew_has_replies' ) ;
    	
    function rew_has_replies( $args = array() ) {
    
    	/** Defaults **************************************************************/
    
    	// Other defaults
    	$default_reply_search   = bbp_sanitize_search_request( 'rs' );
    	$default_post_parent    = ( bbp_is_single_topic() ) ? bbp_get_topic_id() : 'any';
    	$default_post_type      = ( bbp_is_single_topic() && bbp_show_lead_topic() ) ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    	$default_thread_replies = (bool) ( bbp_is_single_topic() && bbp_thread_replies() );
    
    	// Default query args
    	$default = array(
    		'post_type'              => $default_post_type,         // Only replies
    		'post_parent'            => $default_post_parent,       // Of this topic
    		'posts_per_page'         => bbp_get_replies_per_page(), // This many
    		'paged'                  => bbp_get_paged(),            // On this page
    		'orderby'                => 'date',                     // Sorted by date
    		'order'                  => 'ASC',                      // Oldest to newest
    		'hierarchical'           => $default_thread_replies,    // Hierarchical replies
    		'ignore_sticky_posts'    => true,                       // Stickies not supported
    		'update_post_term_cache' => false,                      // No terms to cache
    
    		// Conditionally prime the cache for all related posts
    		'update_post_family_cache' => true
    	);
    
    	// Only add 's' arg if searching for replies
    	// See https://bbpress.trac.wordpress.org/ticket/2607
    	if ( ! empty( $default_reply_search ) ) {
    		$default['s'] = $default_reply_search;
    	}
    
    	// What are the default allowed statuses (based on user caps)
    	if ( bbp_get_view_all( 'edit_others_replies' ) ) {
    
    		// Default view=all statuses
    		$post_statuses = array_keys( bbp_get_topic_statuses() );
    
    		// Add support for private status
    		if ( current_user_can( 'read_private_replies' ) ) {
    			$post_statuses[] = bbp_get_private_status_id();
    		}
    
    		// Join post statuses together
    		$default['post_status'] = $post_statuses;
    
    	// Lean on the 'perm' query var value of 'readable' to provide statuses
    	} else {
    		//get public and pending (not sure if we need this or just to remove the perm status that was here ?
    		$post_statuses = array_keys( rew_get_topic_statuses() );
    	}
    
    	/** Setup *****************************************************************/
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, $default, 'has_replies' );
    
    	// Set posts_per_page value if replies are threaded
    	$replies_per_page = (int) $r['posts_per_page'];
    	if ( true === $r['hierarchical'] ) {
    		$r['posts_per_page'] = -1;
    	}
    
    	// Get bbPress
    	$bbp = bbpress();
    	
    	//now filter the query before execution
    	
    	// Add filter if participant
    	$user_id = get_current_user_id() ;
    	$role = bbp_get_user_role( $user_id );
    	if ($role == 'bbp_participant'  || $role == 'bbp_moderator' || bbp_is_user_keymaster($user_id)) { 
    		add_filter( 'posts_where', 'rew_where' );
    	}
    
    	// Call the query
    	$bbp->reply_query = new WP_Query( $r );
    	
    	
    		// Remove filter
    	if ($role == 'bbp_participant'  || $role == 'bbp_moderator' || bbp_is_user_keymaster($user_id)) { 
    		remove_filter( 'posts_where', 'rew_where' );
    	}
    	
    	// Maybe prime the post author caches
    	if ( ! empty( $r['update_post_family_cache'] ) ) {
    		bbp_update_post_family_caches( $bbp->reply_query->posts );
    	}
    
    	// Add pagination values to query object
    	$bbp->reply_query->posts_per_page = (int) $replies_per_page;
    	$bbp->reply_query->paged          = (int) $r['paged'];
    
    	// Never home, regardless of what parse_query says
    	$bbp->reply_query->is_home        = false;
    
    	// Reset is_single if single topic
    	if ( bbp_is_single_topic() ) {
    		$bbp->reply_query->is_single = true;
    	}
    
    	// Only add reply to if query returned results
    	if ( ! empty( $bbp->reply_query->found_posts ) ) {
    
    		// Get reply to for each reply
    		foreach ( $bbp->reply_query->posts as &$post ) {
    
    			// Check for reply post type
    			if ( bbp_get_reply_post_type() === $post->post_type ) {
    				$reply_to = bbp_get_reply_to( $post->ID );
    
    				// Make sure it's a reply to a reply
    				if ( empty( $reply_to ) || ( bbp_get_reply_topic_id( $post->ID ) === $reply_to ) ) {
    					$reply_to = 0;
    				}
    
    				// Add reply_to to the post object so we can walk it later
    				$post->reply_to = $reply_to;
    			}
    		}
    	}
    
    	// Only add pagination if query returned results
    	if ( ! empty( $bbp->reply_query->found_posts ) && ! empty( $bbp->reply_query->posts_per_page ) ) {
    
    		// Figure out total pages
    		if ( true === $r['hierarchical'] ) {
    			$walker      = new BBP_Walker_Reply();
    			$total_pages = ceil( $walker->get_number_of_root_elements( $bbp->reply_query->posts ) / $bbp->reply_query->posts_per_page );
    		} else {
    
    			// Total for pagination boundaries
    			$total_pages = ( $bbp->reply_query->posts_per_page === $bbp->reply_query->found_posts )
    				? 1
    				: ceil( $bbp->reply_query->found_posts / $bbp->reply_query->posts_per_page );
    
    			// Pagination settings with filter
    			$bbp_replies_pagination = apply_filters( 'bbp_replies_pagination', array(
    				'base'    => bbp_get_replies_pagination_base( bbp_get_topic_id() ),
    				'total'   => $total_pages,
    				'current' => $bbp->reply_query->paged
    			) );
    
    			// Add pagination to query object
    			$bbp->reply_query->pagination_links = bbp_paginate_links( $bbp_replies_pagination );
    		}
    	}
    
    	// Filter & return
    	return apply_filters( 'rew_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query );
    }
    
    function rew_get_topic_statuses( $topic_id = 0 ) {
    
    	// Filter & return
    	return (array) apply_filters( 'bbp_get_topic_statuses', array(
    		bbp_get_public_status_id()  => _x( 'Open',    'Open the topic',      'bbpress' ),
    		), $topic_id );
    }
    
    function rew_where( $where ) {
    	$user_id = get_current_user_id() ;
        global $wpdb;
    	$posts = $wpdb->posts ;
        return $where . " OR ( 
                 ".$posts.".post_author = ".$user_id."
            AND  ".$posts.".post_status = 'pending'
    		                 
        ) ";
    }
    
    add_action ('bbp_theme_before_reply_content' , 'rew_pending' );
    
    function rew_pending () {
    	$id = bbp_get_reply_id() ;
    	$status = get_post_status ($id) ;
    	if ($status == 'pending' ) {
    	echo '<i><b>This reply is pending review and can only be seen by you and the administrators</b></i>' ;
    	}
    	
    }
    #210221

    In reply to: CSS styling query

    Robin W
    Moderator

    nor have I.

    The function is called by core/filters.php

    Line 203: add_filter( 'bbp_get_form_forum_content', 'bbp_code_trick_reverse' );
    Line 206: add_filter( 'bbp_get_form_topic_content', 'bbp_code_trick_reverse' );
    Line 209: add_filter( 'bbp_get_form_reply_content', 'bbp_code_trick_reverse' );

    so you could try

    remove_filter ('bbp_get_form_forum_content', 'bbp_code_trick_reverse' );

    etc.
    in your child theme and see what removing it does

    #210218

    In reply to: CSS styling query

    Chuckie
    Participant

    Thanks.

    I see line 218: $content = "\n<pre>" . $content . "</pre>\n";

    I suppose that could become:

    $content = "\n<pre class=\"suitable-class-name\">" . $content . "</pre>\n";

    And that styling be moved into that class. But:

    Line 133: $content = preg_replace_callback( "!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", 'bbp_decode_callback', $content );

    I have no clue about what that code is doing.

    #210209
    cedluck
    Participant

    Hi there,

    cancasstudio stated :

    So the issue with topic going into pending, is that the topic or reply most likely has invalid formatted code. Example: User type is a URL and hit submit, it is gone. Well, no, it is pending. because https://domain.com/something is not allowed. And the app does tell the user of the error.

    Is there any way we can allow people to type url in there topics/replies?

    #210198

    In reply to: CSS styling query

    Robin W
    Moderator

    the only place I can find <pre> is in

    includes/common/formatting.php line 120 onwards

    #210197

    In reply to: CSS styling query

    Chuckie
    Participant

    Well, the issue here is that bbPress is using a catch all for pre when it should be applying a class to the pre objects that it creates. Then we wouldn’t have this issue would we? Because they would just be classes that are used by either application with their own pre code usage.

    The issue is that I don’t know how or where bbPress makes use of the pre tag so that the logic can be adjusted to use a class to indicate the styling rather than that global pre catch all.

    #210186

    In reply to: add front end editor

    teazmo
    Participant

    Nevermind. I found out, that I‘ve used the wrong shortcode in Notify, so formatting was removed by Notify

    #210184

    In reply to: CSS styling query

    Chuckie
    Participant

    Turns out @robin-w that my additional css is not the solution. When the user clicks “Raw” on the code block it is supposed to toggle the raw code block to be visible. And since I added that css style it has forced it to never display.

    so I need another way for bbpress to do what it wants with pre blocks that does not conflict with enlighterjs.

    #210182
    Robin W
    Moderator

    unfortunately we can’t see that link without login details (which please do not show).

    You should create an ordinary WordPress page, add a block with your text, and then follow this with a shortcode block with

    [bbp-forum-index]

    in it

    #210174
    Alpo
    Participant

    Hi everybody!

    I have users from several places in our service. That means there are also several bbpress- forums in use.

    I am looking for a short code which shows the forums where a user has joined. Do you have any idea? That information is available on the Buddypress profile, but it needs some clicking and our users are frustrated.

    It would be nice to place the short code on sidebar so users can go directly to the forum without clicking hassle 🙂

    Thanks you in advance, bbpress is dynamite 🙂

    #210167

    In reply to: CSS styling query

    Chuckie
    Participant

    For the other issue, the only thing I can come up with is Additional CSS:

    .enlighter-default .enlighter-raw {
    	display:none !important;
    }

    But is there a more robust solution that avoids the need for this?

    #210157
    Chuckie
    Participant

    Hi

    I have some queries and I wonder if you can help me get to the bottom of them. I would be grateful for your guidance. Here is the background.

    I am using the latest bbPress plugin and I notice that the bbpress.css file is 1702 lines long.

    I am using a premium theme (seos-video-premium) and even though I am using a child theme, I have noticed that my Support forum is actually using:

    wp-content/themes/seos-video-premium/seos-video-premium/css/bbpress.css

    I assume this is because there is no bbpress.css in my child theme css folder so it uses the themes one instead of the bbPress plugin’s one?

    So I have two specific questions here.

    1/ the bbpress.css file in the premium theme folder is actually 1408 lines of code. So it is 300+ lines shorter than the plugin version. To be honest, I was not expecting to find a bbpress.css file inside the theme. So what am I supposed to do? Simply replace the theme version with your plugin version?

    2/ I have been trying to use a beta version of EnlighterJS Plugin (it is their beta that uses EnlighterJS v3. There was an issue with these styles:

    #bbpress-forums div.bbp-topic-content pre,
    #bbpress-forums div.bbp-reply-content pre {
    	display: block;
    	line-height: 18px;
    	margin: 0 0 24px;
    	padding: 5px 10px;
    	white-space: pre;
    	overflow: auto;
    }

    In their classes they have this styling:

    .enlighter-default .enlighter-raw {
        display: none;
        min-width: 100%;
        line-height: inherit;
        font-size: 12px;
        font-family: inherit;
        margin: 0;
        padding: 0;
        white-space: pre-wrap;
        word-wrap: break-word;
        border: none;
        box-shadow: none;
    }

    The HTML is:

    <pre class="enlighter-raw">.textMaterial {
      /* Uncomment to hide the material */
      /* display:none;*/
      font-size: 10pt;
      font-style: italic;
      font-weight: 700;
      background-color: yellow;
    }
    .textMethod {
      /* Uncomment to hide the method */
      /* display:none;*/
      font-size: 10pt;
      font-style: italic;
      font-weight: 700;
      background-color: cyan;
    }</pre>

    Notice that ttheir CSS style uses display: none;? The bbpress CSS file pre class has a display:block;. This causes a problem with the plugin I am trying to use.

    The author does not want to use !important because he says it is bad design. So how do we fix this? How can we allow bbpress to do what it wants with pre and EnlighterJS do what it wants?

    #210151

    In reply to: Forum roles issue

    Robin W
    Moderator

    yes, participants should be able to create topics and replies viz :

    bbPress User Roles and Capabilities

    I strongly suspect the issue is with active directory, you already have said that it rolls back settings, which makes me suspect that the entire WordPress database is being rolled back – if you create say a test post on the website, does it stay overnight, or does it disappear – this would help determine where to go next.

    #210139
    antonv
    Participant

    I needed to restrict participant topic creation to selected forums but allow replies to all topics in all forums. I came up with this solution

    function my_bbp_restrict_topic_creation( $can ) {
    		
    	$forum_id = array(18,22,56); //change your forum id
    
    	if ( ! bbp_is_user_keymaster() &&  bbp_is_single_forum() &&   !in_array( bbp_get_forum_id(),$forum_id) ) {
    		$can = false;	
    	}
    
    	return $can;
    
    }
    add_filter( 'bbp_current_user_can_publish_topics', 'my_bbp_restrict_topic_creation' );  

    Participants can only create topics in the three forums with IDs 18,22,and 56. Whereas the KeyMaster can create topics in all forums.

    #210133
    Robin W
    Moderator

    I did a code search and found this function in includes/common/functions line 1507 which seems a highly likely candidate.

    function bbp_logout_url( $url = '', $redirect_to = '' ) {
    
    	// If there is no redirect in the URL, let's add one...
    	if ( ! strstr( $url, 'redirect_to' ) ) {
    
    		// Get the forum root, to maybe use as a default
    		$forum_root = bbp_get_root_url();
    
    		// No redirect passed, so check referer and fallback to request uri
    		if ( empty( $redirect_to ) ) {
    
    			// Check for a valid referer
    			$redirect_to = wp_get_referer();
    
    			// Fallback to request uri if invalid referer
    			if ( false === $redirect_to ) {
    				$redirect_to = bbp_get_url_scheme() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    			}
    		}
    
    		// Filter the $redirect_to destination
    		$filtered  = apply_filters( 'bbp_logout_url_redirect_to', $redirect_to );
    
    		// Validate $redirect_to, default to root
    		$validated = wp_validate_redirect( $filtered, $forum_root );
    
    		// Assemble $redirect_to and add it (encoded) to full $url
    		$appended  = add_query_arg( array( 'loggedout'   => 'true'   ), $validated );
    		$encoded   = urlencode( $appended );
    		$url       = add_query_arg( array( 'redirect_to' => $encoded ), $url       );
    	}
    
    	// Filter & return
    	return apply_filters( 'bbp_logout_url', $url, $redirect_to );
    }

    so maybe filtering on ‘bbp_logout_url’ would work.

    Let me know if you need further help

    #210131
    ricks033
    Participant

    I have two websites running custom php to create Log In/Log Out entries on the menu.

    The Log Out behavior is different on the two websites. I finally tracked down the problem to bbPress. The URL created by my custom code with w_logout_url() on the bbPress site includes:
    &redirect_to=…

    where the URL created by the site without bbPress installed does not.

    Disabling bbPpress removes the &redirect_to=… and reenabling bbPress makes the redirect_to return.

    That leads me to believe bbPress is changing /setting this value somewhere, but I don’t see any choice to change that value in the bbPress settings?

    add_filter( 'wp_nav_menu_items', 'ccc_add_loginout_link', 10, 2 );
    function ccc_add_loginout_link( $items, $args ) {
        if (is_user_logged_in() && $args->theme_location == 'header-menu') {
            $items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
        }
        elseif (!is_user_logged_in() && $args->theme_location == 'header-menu') {
            $items .= '<li><a href="'. site_url('wpflogin') .'">Log In</a></li>';
        }
        return $items;
    }

    Thanks!!

    #210130
    giovanni
    Participant

    Hi,
    I don’t understand why it’s shown the pagination in user profile page.
    I’m refering to this page: https://www.make4future.com/forums/users/giovanni/

    I was thinking of hiding it with css for example:
    .pagination { display:none; }

    But the question is:
    what is it caused by ?
    There is a better way to resolve the problem ?

    Thanks in advance !

    Regards,
    Giovanni.

    Robin W
    Moderator

    can you list your plugins please- the original error
    Line 1: <div class="error"> <p>This Plugin needs BBpress to work, pls. install it first and activate.</p></div>

    is not from bbpress

    Solitary_bee
    Participant

    Yes I get that, and I see my settings are configured to automatically now give this status to new additions, and supposedly the ability to post, but ‘half’ of those that already have the status cannot.

    It’s a real shame that there are no codes written into the error messages.

    I guess my two questions are (in the context of my above post)

    1. When did all my historically inactive users get all their statuses changed to participants, it could only be with a recent BBpress plugin update?
    2. Is there another encoded condition that has to be satisfied aside from “if user = Participant then validate post or reply?”.

    I know an invalid or heavy file may stop posting, but I have increased the values of the attachments so this is out. Failed posters have however not always been uploading anything more than their text.

    Anyway I should stop speculating and see when the successful and failed posters were entered into the system.

    #210117
    webcreations907
    Participant

    <!-- nextpage-> converts to paginated links when using wp_link_pages() WordPress function for pages, posts, etc content, some themes add it some may not. As stated on WordPress wp_link_pages() must be in a loop/used for post content output.

    I don’t think(maybe wrong) that it would be a good idea to use it in topics and replies for bbpress since bbpress has it’s own pagination functionality.

    Thought I’d mention it. 🙂

    #210107
    Robin W
    Moderator

    hmm..not come across this before, from googling seems to be a wrodpress.com thing – doesn’t mean that I’m right – there’s tons on the internet that I don’t know, but just tried <!-- nextpage-> on posts in a couple of test sites, and it does nothing.

    Can only suggest you find out what is adding it, but you may need to accept that it doesn’t work in bbpress

    #210106
    Juha Metsäkallas
    Participant

    Eh, I’ve thought that that code is built in into WP. If that is not the case, then it must come with some of the bundles that accompany my theme. Could it be Kirki Customizer Framework?

    #210102
    Juha Metsäkallas
    Participant

    I tried to fix some typos, but it seems that it was interpreted as breach. Let me try anew.

    Steps to reproduce.

    1. Have the lorem ipsum text with <!--nextpage-->

    >
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    <!–nextpage–>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    <

    2. If I create a page in my site with that text (and only that text), I see the first part and the navigation to the second part as my theme defines. The navigation works i.e. by clicking I can go to the second part.

    3. If I create a topic in my bbPress forum with that text (and only that text), I see the first part and the navigation to the second part as my theme defines. However the navigation does not work, i.e. by clicking I get the “too many redirects” error.

    #210091

    In reply to: bbPress + Elementor

    jaffray
    Participant

    I got it working without needing to modify the code. Use Single – “Any Child Of” – form name.

Viewing 25 results - 2,876 through 2,900 (of 32,453 total)
Skip to toolbar