Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,101 through 1,125 (of 32,480 total)
  • Author
    Search Results
  • #230209

    In reply to: Edit Topic Page

    wdseocompany
    Participant

    Hi Robin,
    Thanks for the info on this one; I’ve managed to get this resolved. In essence I was overcomplicating the problem.

    I disabled the templates I had setup so the page could just return all the default content and the edit functionality was working. Instead of using the custom code snippet I just used the ‘Post Content’ module in Divi which worked beautifully.

    Coming back to it with a fresh set of eyes and taking it back to basics helped a lot haha!

    Thanks again Robin for your help, all the best!

    Kind regards,
    Matt P

    #230174
    Robin W
    Moderator

    so you are happy that in the forum display, the topic content box will be there, but show nothing ?

    for 1,3&4

    #bbpress-forums fieldset.bbp-form input[type="text"] {
    	width: 100% !important;
    }
    div.bbp-submit-wrapper {
    width: 100%;
    }

    add this to the custom css of your theme

    Robin W
    Moderator

    ok, I’ve found time to take an initial look at this.

    The function called looks at a database item which holds the sub forum count – but it looks like this is just count of public forums, so the count is zero, so none displayed.

    so removing looking at this takes away the issue.

    It would take a deal of work to see why and how to make a permanent fix to this, and I think this filter will do what you want

    
    add_filter('bbp_forum_get_subforums', 'rew_forum_get_subforums', 10, 3);
    
    function rew_forum_get_subforums( $sub_forums, $r, $args ) {
    
    	// Default return value
    	$retval = array();
    	
    	// Use passed integer as post_parent
    	if ( is_numeric( $args ) && ! empty( $args ) ) {
    		$args = array( 'post_parent' => bbp_get_forum_id( $args ) );
    	}
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, array(
    		'post_parent'         => 0,
    		'post_type'           => bbp_get_forum_post_type(),
    		'posts_per_page'      => get_option( '_bbp_forums_per_page', 50 ),
    		'orderby'             => 'menu_order title',
    		'order'               => 'ASC',
    		'ignore_sticky_posts' => true,
    		'no_found_rows'       => true
    	), 'forum_get_subforums' );
    
    	// Ensure post_parent is properly set
    	$r['post_parent'] = bbp_get_forum_id( $r['post_parent'] );
    	
    	
    	// Query if post_parent has subforums
    	if ( ! empty( $r['post_parent'] )  ) {
    		$get_posts = new WP_Query();
    		$retval    = $get_posts->query( $r );
    	}
    	// Filter & return
    	return (array) apply_filters( 'rew_forum_get_subforums', $retval, $r, $args );
    	
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

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

    or use

    Code Snippets

    Robin W
    Moderator

    This is not fully tested, but should work

    add_filter( 'bbp_get_reply_edit_url', 'rew_admin_link', 10 , 2 ) ;
    
    function rew_admin_link ($url, $reply_id ) {
    	if ( bbp_is_user_keymaster(get_current_user_id())) { 
    	$url = '/wp-admin/post.php?post='.$reply_id.'&action=edit' ;
    	}
    return $url ;
    }
    #230140
    scmsteve
    Participant

    We are also seeing this, it took quite a while to track it down to this. Adding the code provided here seems to make the editor visible/work again.

    Another issue we are having, though, is the display of emoticons or whatever they are called that were inserted via TinyMCE…

    We get a 404 error on the URL formed like this:

    /forum/my-plugins/tiny_mce/plugins/emotions/img/smiley-smile.gif

    #230132
    neon67
    Participant

    add to css

    transform: rotate(5deg) translateY(-10%);
        transform-origin: top left;
    coopersita
    Participant

    Thanks. I actually rolled my own solution with the post anonymously checkbox. I’m not too concerned that people will post with their names by mistake and be too upset. Here’s the code I’m using in case someone else is looking. For this setup to work, you just need to create an “anonymous’ user, so all topics that are flagged will be attributed to the user and the original user id is saved as a meta field so the system isn’t abused (so mostly anonymous, but not completely):

    //Anonymous publishing in forums
             //add fields to form (checkbox)
             add_action ( 'bbp_theme_after_topic_form_content','bbp_extra_fields');
             //save fields and change author
             add_action ( 'save_post_topic', 'bbp_save_extra_fields', 10, 2);
             //display original author for admins above topic
             add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields');
    
        function bbp_extra_fields() {
           $value = get_post_meta( bbp_get_topic_id(), 'is_anonymous', true);
            echo "<input type='checkbox' name='is_anonymous' id='is_anonymous' value='yes' ".checked('yes', $value)."> &nbsp;";
            echo '<label for="is_anonymous">Post this topic anonymously</label>';
            echo '<p><strong>Note:</strong> By checking this box, your identity will be hidden from other participants, but not from moderators nor admins. </p>';
        }
        
        function bbp_save_extra_fields( $post_id, $post) {
            if(isset($_POST['is_anonymous']) && $_POST['is_anonymous'] === 'yes') {
                $anon_ID = 1; // Id of dedicated anonymous user
                // update post if it's not anonymous already
                if($post->post_author != $anon_ID) {
                    update_post_meta($post_id, 'is_anonymous', $post->post_author);
                    wp_update_post( array(
                        'ID' => $post_id,
                        'post_author' => $anon_ID 
                    ) );
                }
            }
        }
        
        function bbp_show_extra_fields() {
            if(current_user_can('delete_others_topics')) {
              $topic_id = bbp_get_topic_id();
              $anon_author = get_post_meta( $topic_id, 'is_anonymous', true);
              if($anon_author) {
                    $user = get_user_by('ID', intval($anon_author));
                    if($user) {
                        echo "Original Author: <a href='".site_url()."/forums/users/".$user->user_login."'>".$user->display_name."</a><br>";
                    }
                }
            }
        }

    The code is only for posting topics. I’m not sure if for my use case replies would also need to be anonymous. We mostly want people to be able to ask questions openly without fear of being recognized by their peers (some users know each other).

    Robin W
    Moderator

    Alternatively, is there a way to post completely anonymously, but in a way that is available only for logged-in users?

    I think you’ve asked this before, but not sure I responded.

    It is technically possible, but lots of code and beyond free help. In any case I’d suspect that someone would post thinking it was anonymous, but forget to tick the box that says anonymous, or use the wrong form, and by mistake post something outrageous that then appears in their name, cue them accusing your site of destroying their reputation, you accusing whoever wrote the code of it not being robust, and all hell breaking loose. So not code that I would write.

    your other suggestion is also possible, but you’d need to catch everywhere the username is used, and again risk it being exposed in some code that isn’t expected.

    I s’pose my gut answer is just enable anonymous posting, and use the ‘hold for moderation’ in the moderation part of my style pack plugin to approve anonymous posts. Then tell your users that they must log out to post anonymously.

    #230106

    In reply to: Edit Topic Page

    wdseocompany
    Participant

    Just for information the theme is Divi, using their theme builder allowing me to style and format whole taxonomies a little easier (in theory haha)

    For the bits of PHP – This is what I’m using to pull in the information for singular forums:
    $page_id = get_queried_object_id();
    $dynamic_forum_shortcode = ‘[bbp-single-forum id=' . $page_id . ']‘;
    echo do_shortcode($dynamic_forum_shortcode);

    And for topics as follows:
    $page_id = get_queried_object_id();
    $dynamic_topic_shortcode = ‘[bbp-single-topic id=' . $page_id . ']‘;
    echo do_shortcode($dynamic_topic_shortcode);

    So in theory the idea is:
    1. Pull in page id as identifier
    2. Form shortcode for forum/topic
    3. Add these PHP snippets to the Divi template using the Code Snippets plugin

    Then when someone accesses the page it should call in topic/forum based on the ID of the page

    I’ll take a look into this tomorrow, changing theme and disabling plugins as thankfully it isn’t live just yet. Thanks for your help so far anyway but if you can spot any flaw in the logic so far please do alert me!

    #230105

    In reply to: Edit Topic Page

    Robin W
    Moderator

    ok, so presuming this is in any topic, then if you fancy sharing the shortcode you are using and the php code, I might take a look at that

    Outside of your php code, I’d suggest it could be a theme or plugin issue

    Themes

    As a test switch to a default theme such as twentytwenty, and see if this fixes.

    Plugins

    If that doesn’t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.

    If you cannot do this to your site (say because it is live) then use the ‘troubleshooting’ features of this plugin to let you test without affecting other users

    Health Check & Troubleshooting

    Then come back

    #230092
    wdseocompany
    Participant

    Hi there,

    Just wondering if anyone would be able to assist with an issue I’m experiencing on a site we’re working on. Unfortunately unable to share a link due to the nature of the project.

    Summary: When clicking on the edit button on the front end of topics as any role it redirects to a page showing all posts, on all forums in date order.

    Setup: The way this information is pulled in to the page is using the shortcodes to pull in the topic information, using PHP to get the id of the page (in turn, the topic), adding it to the shortcode and then executing it.

    This seems to be working well to date aside from the editing of the topic; as the reply function is working nicely. Basically as soon as it pops in the /edit at the end of the URL it doesn’t show the right info.

    Any advice would be fantastic, again I know it is difficult without a URL however any suggestions would be great.

    Kind Regards,
    Matt P

    #229916
    Robin W
    Moderator

    thanks for posting. The site needs access to replicate so cannot be reproduced without.

    bbpress does not have a WYSIWYG editor by default, so what code/plugin are you using to get this? I’d suspect your theme may be doing this, and therefore may be creating the problem.

    You also have an error in your theme (Use of undefined constant bbp_reply_id ), which is either code you have added to what looks like a parent theme, or an error in the theme itself.

    I’d suggest that you prove this by

    Themes

    As a test switch to a default theme such as twentytwenty, and see if this fixes.

    Plugins

    If that doesn’t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.

    If you cannot do this to your site (say because it is live) then use the ‘troubleshooting’ features of this plugin to let you test without affecting other users

    Health Check & Troubleshooting

    Then if it is theme contact the theme author as it is a paid theme

    #229864

    Most embeds can be disabled via the “Auto-embed links” setting in:

    Admin > Settings > Forums

    You can also permanently unhook them:

    remove_action( 'bbp_init', 'bbp_reply_content_autoembed', 8 );
    remove_action( 'bbp_init', 'bbp_topic_content_autoembed', 8 );
    

    Images are a bit trickier, as you’ll need to remove img from the allowed-tags array:

    add_filter( 'bbp_kses_allowed_tags', function( $tags = array() ) {
        unset( $tags['img'] );
        return $tags;
    } );
    
    #229861

    bbPress includes a function called bbp_make_clickable that is used to turn regular URLs in topic and reply contents into anchors.

    You would need to unhook it to prevent it from happening.

    remove_filter( 'bbp_get_reply_content', 'bbp_make_clickable', 40 );
    remove_filter( 'bbp_get_topic_content', 'bbp_make_clickable', 40 );
    
    #229859

    In reply to: Shortcodes and WP 6.0

    Robin W
    Moderator

    🙂 not as far as I know – many thousands of plugins use shortcodes, and WP would create massive issues if they stopped them.

    #229857

    In reply to: Shortcodes and WP 6.0

    Robin W
    Moderator

    So is this one article, or many, is it written by someone with expert knowledge or does it cite some authority?

    reddit is just people chatting, so without anything more substantive, I can’t say, I’ve seen nothing.

    Shortcodes just execute the same code that a block would, just with a different initiation, so hard to see how anyone can say they are slow.

    There’s a flat earth community on reddit as well 🙂

    #229853
    sonalsinha21
    Participant

    Hi,

    Normally bbpress changes any URL to link or gives img tag etc.

    Is it possible that we don’t have anything visual and have only plain text based response?

    I am asking this because people respond to support forum with all sorts of links which goes to 404 on a later date.

    Having it as a code based and not actual link will mean no more 404 in future.

    #229849

    In reply to: Shortcodes and WP 6.0

    neon67
    Participant

    On reddit ))))) Are these rumors?
    Okay, what’s the best way integrate bbpress with Guttenberg’ blocks today?
    Only shortcodes or some other method…

    #229842

    In reply to: Shortcodes and WP 6.0

    Robin W
    Moderator

    However, I read that shortcodes are already outdated and work quite slowly.

    where did you read this?

    #229834
    neon67
    Participant

    I’m inserting a tracker shortcode into the main page.
    However, I read that shortcodes are already outdated and work quite slowly.
    What is the shortcodes alternative ?
    Is there a more modern way to paste Guttenberg blocks?

    #229799
    Robin W
    Moderator

    and indeed on my profile on this site as

    xvcxvczvzc

    #229780
    uksentinel
    Participant

    Is there any update on this thread, looking to achieve exactly the same by adding a Locked / Closed tag (icon) when a topic is closed ?

    I have already used the code to ensure text does not turn Grey, so just looking to add some form of symbol so forum users can see topic thread has been closed

    Thanks

    BTW – for reference for others, code to stop Closed Topics text changing to Grey is …

    #bbpress-forums .status-closed,
    #bbpress-forums .status-closed a {
    color: #000 !important;
    }

    #229716
    andreiandronachi95
    Participant

    Hello everyone! I have a problem with one topic and I don’t know what to do. That specific topic have 3 replies(2 from admin and 1 from the user that post it). If I enter in admin I can see those replies, if I enter in db I also cand see them, but on the frontend is empty. Firstly I thought all the replies are hidden but they are not render on the frontend. I watched on other topics and everything works fine. What can it be? Thank you!
    If I put
    `
    $a = array(
    ‘post_type’ => ‘reply’,
    ‘post_parent’ => bbp_get_topic_id()
    );
    $b = get_posts($a);
    var_dump($b);
    `
    On others topics I can see the replies but on that one is an empty array

    #229662
    Robin W
    Moderator

    2nd issue – put this in your custom css

    .archive-description {
    display : none ;
    } 

    3rd issue

    bbp style pack

    #229631
    Robin W
    Moderator

    Apologies, I’ve been tied up in a paid project, and this had slipped from my memory.

    The actual code that does the work is a few lines, but it needs wrapping in lots of checks and stuff that limits, but I’m back looking at it now 🙂

Viewing 25 results - 1,101 through 1,125 (of 32,480 total)
Skip to toolbar