Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 901 through 925 (of 32,297 total)
  • Author
    Search Results
  • Robin W
    Moderator

    ok,

    1. create a page called ‘profile’, it needs no content, but make sure the permalink is ‘profile’
    2. in dashboard>settings>wp members>pages>profile select the profile page

    then use this code

    add_action( 'template_redirect' ,'rew_profile' ) ;
    
    function rew_profile () {
    	update_option ('rewurl' , $_SERVER['REQUEST_URI']  ) ;
    	if ($_SERVER['REQUEST_URI']   ==  '/profile/') {
    	$user_id =get_current_user_id() ;
    	$url = bbp_get_user_profile_url( $user_id ) ;
    	exit( wp_redirect( $url ) );
    		}
    }

    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

    gtatar
    Participant

    Thank you, Robin. I added the snipped, and it partially worked. The anchor text “time ago” now reflects the time of the latest good post. However the URL is for the latest spam post.

    I started digging a bit through bbpress code. It looks like if the fix was inside bbp_topic_freshness_link() it would be much easier to test, as we would not need to wait for a new spam post to test the fix. And perhaps make decisions based on the wp_post status having the value “publish”. This way the solution would not be specific to Akismet. But I am really too new to WordPress coding and bbPress to be making this kind of changes myself.

    Robin W
    Moderator

    if it works for a topic, then I’ll do the code for a reply, which is basically changing mthe word topic to reply 🙂

    Robin W
    Moderator

    ok, give this a try – it may or may not do the trick !!

    add_action ('bbp_new_topic_post_extras', 'rew_spam_update_last_active', 10 ,1 ) ;
    
    function rew_spam_update_last_active ($topic_id) {
    	//this function tests if a new topic has been marked as spam by Akismet.  If so then the last active date will be wrong
    	//So we use topic walker to recalculate it
    	if (!empty (get_post_meta( $topic_id, '_bbp_akismet_user_result' ))) {
    	bbp_update_topic_walker ($topic_id) ;
    	}
    }

    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

    yes it does (and does so on here as well!).

    I’m just a helper here, not a bbpress author.

    I don’t run akismet on my test site. Are you able to replicate the problem so that we can check a fix if I am able to work up some code?

    #230255

    In reply to: @mentions for bbpress

    saltywd
    Participant

    Hello Robin, Thanks for the quick reply. I have that plugin but it doesnt seem to work at all. I cant even see that it has any settings anywhere. I do have active right now, WP with Avada Theme, BBPress, bbp Style pack, bbpress notify, GD bbpress Attachments, and Ultimate Member and a few of its extensions for bbpress as it is a private forum.

    on bbp style pack there is a check box to make @mentions help, but says you need buddypress or bbp-mentions-email-notifications which I have tried that plugin and it doesnt work either.

    Would love to use your plugin but i cant get it to work at all.

    I see on GIST there is some code for a bp-custom.php file which includes this

    <?php
    /** You could put this in the bp-custom.php file 
     * @see https://codex.buddypress.org/themes/bp-custom-php/
     */
    function custom_bbpress_maybe_load_mentions_scripts( $retval = false ) {
    	if ( function_exists( 'bbpress' ) && is_bbpress() ) {
    		$retval = true;
    	}
    
    	return $retval;
    }
    add_filter( 'bp_activity_maybe_load_mentions_scripts', 'custom_bbpress_maybe_load_mentions_scripts' );
    #230234
    rinh
    Participant

    My post disappeared and I’m unable to post it again: I’ll try again

    I messed around with the conditions in the theme builder last night and I found working solutions 🙂

    Elementor template for single topic and single forum

    This template will work for single topics (those pages where you read a topic and can reply) and single forum (where you see a list of topics, sometime called boards or category). Both of these act as single posts. Make a Single post template according to your needs and in the container/section where you want bbPress itself put an Archive Posts widget and set the skin to Full Content. It’s going to look like your blog posts in Elementor editor, but it’s normal.

    Save the template with the following conditions:

    Include: All Singular
    Exclude: Posts (unless you want the same template for your posts)
    Exclude: any custom post types you may have
    Exclude: Pages (just to be safe)
    Exclude: you may need to exclude additional things according to your needs.

    Elementor template for forum index

    This template will work for the forum index only. Create and Archive template according to your needs. In the container/section where you want bbPress itself put bbPress forum index shortcode which can be found here: https://codex.bbpress.org/features/shortcodes/

    Save the template with the following conditions:

    Include: Forums Archive

    #230227
    Robin W
    Moderator
    #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.

Viewing 25 results - 901 through 925 (of 32,297 total)
Skip to toolbar