Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,026 through 1,050 (of 32,431 total)
  • Author
    Search Results
  • #230304
    coopersita
    Participant

    Is there a way to redirect all profile page links so they use the user id, instead of user login/nicename? Some users have their email as their username, so we want to hide it.

    So to go from
    /forums/users/{login}

    to
    /forums/users/{id}

    I was able to change the URLs so they point to the right place:

    function bbp_custom_author_link(  $url,  $user_id,  $user_nicename){
                $url = site_url()."/forums/users/".$user_id;
    	   return $url;
        }
        add_filter( 'bbp_get_user_profile_url', 'bbp_custom_author_link', 10, 3);

    But once you click on the link, you end up in a 404.

    janecarole
    Participant

    Thank you, Robin, that worked. So grateful for you! Please provide me the link you gave me before (on a different topic) so I can thank you meaningfully ($) for your research/coding for me!

    I ended up creating a link on my “Member Profile” page to the new “profile” page you had me create. (I did this so the user would still see WP-Members “Member Profile” page with its unique information.) I used Code Snippets to add your code.

    Not that you need to know this, but: Right after making this change, I had to restore my site because a plugin update (WP-Crontrol) broke the site, and it wouldn’t load. The restore fixed that problem, but caused a problem with my Wordfence connection which messed up my site log-in. It took a while to figure that one out, but after disconnecting and reconnecting Wordfence, I am back to normal (except for needing to make your change again 🙁 …). Plan to do that later.

    Robin W
    Moderator

    or might not – I’m trying to look at this in limited free time and trying not to get sucked into too deeper a code dive 🙂

    #230292
    rinh
    Participant

    Sorry for double post, but I got the toggle button back by adding wp_adv, as well as the image button. Full code below if anyone needs it too

    function bbp_enable_visual_editor( $args = array() ) {
      
        $args['tinymce'] = array('toolbar1' => 'formatselect, bold, italic, underline, bullist, numlist, blockquote, alignleft, aligncenter, alignright, link, image, wp_adv');
        $args['quicktags'] = false;
        $args['teeny'] = false;
    
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );

    For toolbar 2 I hid the unwanted buttons with CSS. I’m happy with the results 🙂 Still curious though if toolbar 2 can be customised, but it’s nothing necessary.

    #230290
    rinh
    Participant

    Hi,
    I’m trying to customise the toolbar in TinyMCE.

    Initially I just enabled the advanced one:

    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        $args['teeny'] = false;
        $args['quicktags'] = false;
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );

    I thought of adding a button for underline and it led to trying to get only what I needed in one toolbar:

    function bbp_enable_visual_editor( $args = array() ) {
      
        $args['tinymce'] = array('toolbar1' => 'formatselect, bold, italic, underline, bullist, numlist, blockquote, alignleft, aligncenter, alignright, link, strikethrough, forecolor, outdent, indent, undo, redo');
        $args['quicktags'] = false;
        $args['teeny'] = true;
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );

    This is causing it to repeat some things in toolbar 2 (as well as the ability to toggle toolbar 2 on and off). I tried adding toolbar 2 to the code above, but then it goes back to default. I could stop there though and just add underline and the tools that’s in toolbar 1 by default, but I’m curious if I can customise things further.

    To my question:
    Is there a way to add everything in one toolbar and then disable toolbar 2?
    Or is there a way to get the toogle for toolbar 2 back when I’ve customised toolbar 1?

    I also tried enabling teeny which would’ve worked best, but then I lose the forecolor toolbar box so I’d need a way to add it back.

    Thanks in advance

    Robin W
    Moderator

    maybe it’s the if function, try

    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
    	bbp_update_topic_walker ($topic_id,  '', 0, 0, true) ;
    	}

    It’s not the answer, but might help get to the solution problem

    Robin W
    Moderator

    So there is some code in bbpress that can fix the link (I am guessing by changing something in the database?).

    yes it is the function ‘bbp_update_topic_walker ‘ called in my code 🙂 🙂

    I’ll look further at why it isn’t recalculating based in that info

    gtatar
    Participant

    Still the same result with the new code.

    But I noticed that emptying the spam folder causes “Last Post” link to change to the correct value. So there is some code in bbpress that can fix the link (I am guessing by changing something in the database?).

    Robin W
    Moderator

    ‘It looks like if the fix was inside bbp_topic_freshness_link() it would be much easier to test, ;’

    agree but it just wouldn’t work there, that is not where or when the issue is occurring.

    Try

    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,  '', 0, 0, true) ;
    	}
    }
    
    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.

Viewing 25 results - 1,026 through 1,050 (of 32,431 total)
Skip to toolbar