Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 4,826 through 4,850 (of 32,518 total)
  • Author
    Search Results
  • #187716
    super powered
    Participant

    Relevant tag validation code for above since I had to write it for my project anyways:

    
    
    function new_reply_pre_set_terms_tag_test($terms, $topic_id, $reply_id)
    {
        //Bail Early if not set
        if(!$terms)
            return $terms;
    
        //Bail early if we are allowed to modify tags
        if(current_user_can( 'modify_topic_tags' ))
            return $terms;
    
        if(!is_array($terms))
            $terms = explode(', ', $terms);
    
        //For each to check if array term already exists. Remove if doesnt
        foreach ($terms as $tag => $tag_value):
            if(!term_exists($tag_value, 'topic-tag')):
                unset($terms[$tag]);
            endif;
        endforeach;
    
        return implode(', ', $terms);
    }
    
    function new_topic_pre_insert_tag_test($data)
    {
        //Bail Early
        if(!is_array($data) || !isset($data['tax_input']) || !isset($data['tax_input']['topic-tag']))
            return $data;
    
        //Bail early if we are allowed to modify tags
        if(current_user_can( 'modify_topic_tags' ))
            return $data;
    
        //Make sure we're an array
        if(!is_array($data['tax_input']['topic-tag']))
            $data['tax_input']['topic-tag'] = array($data['tax_input']['topic-tag']);
    
        //For each to check if array term already exists. Remove if doesnt
        foreach ($data['tax_input']['topic-tag'] as $tag => $tag_value):
            if(!term_exists($tag_value, 'topic-tag')):
                unset($data['tax_input']['topic-tag'][$tag]);
            endif;
        endforeach;
    
        return $data;
    }
    
    add_filter('bbp_new_reply_pre_set_terms','new_reply_pre_set_terms_tag_test', 22, 3);
    add_filter('bbp_edit_reply_pre_set_terms','new_reply_pre_set_terms_tag_test', 22, 3);
    add_filter('bbp_new_topic_pre_insert','new_topic_pre_insert_tag_test');
    
    
    #187715
    super powered
    Participant

    The reason the function doesn’t work is because BBPress throws a fatal error when it tries to handle the array of items when it expects it as a string. We probably just need to get a filter in the core that allows us to manipulate that value before it tries to use the split() function.

    Until then, kind of a hacky workaround is to use JS to append the values to a hidden field:

    
    function display_tag_elements($selectedTags, $userRole, $task)
    {
        $html = array();
        $tags = get_categories(array('hide_empty' => 0, 'taxonomy' => 'topic-tag'));
        $selectedTagsArray = explode(', ', $selectedTags);
        if ($userRole != 'bbp_participant' || $task != 'edit')
        {
            $html[] = "";
            foreach ($tags as $tag)
            {
                $selected = '';
                if (in_array($tag->name, $selectedTagsArray))
                {
                    $selected = 'checked';
                }
                $html[] = "<input type='checkbox' class='bbp_topic_tags_checkbox' name='bbp_topic_tags_checkbox[]'" . $selected . " value='" . $tag->name . "'>" . $tag->name . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            }
    
            $html[] = "<input type='hidden' class='bbp_topic_tags_hidden' name='bbp_topic_tags' value='".$selectedTags."'>";
    
            $html[] = "
                <script>
                    var checkboxes = document.getElementsByClassName('bbp_topic_tags_checkbox');
                    var hidden = document.getElementsByClassName('bbp_topic_tags_hidden');
                    var hiddenVal = hidden[0].value.split(', ');
                    
                    for(var x = 0; x < checkboxes.length; x++)
                    {
                        checkboxes[x].addEventListener( 'change', function() 
                        {
                            var index =  hiddenVal.indexOf(this.value);
                            var checked = this.checked;
                            if(checked && !index > -1) 
                                 hiddenVal.push(this.value);
                            else if (!checked && index > -1)
                                 hiddenVal.splice(index, 1);
                            
                             hidden[0].value = hiddenVal.join();
                        });
                    }
                </script>
            ";
        } else
        {
            $html[] = $selectedTags;
        }
    
        return implode('', $html);
    }
    
    

    However this has a pretty notable downside in that someone could just inspect the code and add whatever they want to the hidden field. So you’ll want to make sure your also using one of the spam filters like bbp_new_reply_pre_set_terms to make sure the new values are terms you’ve predefined.

    Side note: there also seems to be a pretty annoying bug in that participants can edit the topics tags on reply, so I would just disable it on reply for non-moderators.

    EDIT: kind of like I just did. I don’t think I should be allowed to add tags to existing topics. this feels like a bug.

    #187708

    In reply to: Quote

    ico33
    Participant

    Anybody knows a code to insert for having quote?

    #187703

    In reply to: Delete own posts

    sarwarc
    Participant

    Hi LeGuerg,

    Thanks for the useful post. I have added those lines of code in two php files that you mentioned, but still particants can’t delete their own posts.

    /home/XXX/public_html/XXX/wp-content/plugins/bbpress/includes/replies/capabilities.php
    /home/XXX/public_html/XXX/wp-content/plugins/bbpress/includes/topics/capabilities.php

    Any idea why? Anyone’s help will help will be greatly appreciated.

    #187693
    carajoan
    Participant

    I’m having this problem after trying this solution, searching the codex and this forum. Here are all the various solutions I’ve tried:

    .reply {
        color: #000000 !important;
    }
    
    #commentform #submit, .reply, #reply-title small {
        background-color: #000000;
        color: #ffffff;
    }
    
    .forum a { color: black !important; }
    
    .bbp-forum-info { color: black !important; }
    
    .bbp-forum-topic-count { color: black !important; }
    
    .bbp-forum-reply-count { color: black !important; }
    
    .bbp-forum-freshness { color: black !important; }
    
    .bbp-topics {
    color: black !important;
    background-color:white;
    }
    
    .bbp-forums a { color: black !important; }
    
    #bbpress-forums div.bbp-topic-content a,
    #bbpress-forums div.bbp-reply-content a {
    	background-color: white;
    }
    
    #bbpress-forums div.even,
    #bbpress-forums ul.even {
     background-color: #fff;
    }
     
    #bbpress-forums div.odd,
    #bbpress-forums ul.odd {
     background-color: #fbfbfb;
    }
    
    /*styling to move 'Subscribe' to right hand side */
    .single-forum .subscription-toggle  {
        float:right !important ;
    }
    #187679
    jerichox
    Participant

    I would like to add the Recent Topic Widget to the Footer of my page, however it does not match the format.. I have opened the widget.php file and found it but keep getting stuck on the code.. Any ideas/help?

    Below is the link.. I would like the recent topics to match the recent posts part of the footer..
    http://piw.ewarena.com/2017/10/another-news-test/

    #187675
    Tony
    Participant

    I have two forums and I have two non-bbPress widgets. I’ve setup the widgets to show up on forum pages with the Widget Options plugin. Each of the forums need to show only the menu that pertains to it (match by state name). As of now, both widgets show up on both forum pages.

    Tried conditional tag: is_bbpress() with the page ID’s, but it doesn’t change anything. None of my researched plugins seem to have this feature figured out.

    Any ideas? Still fairly new to all this and not a coder so don’t have the best vernacular for troubleshooting.

    WP version: 4.8.2
    bbPress version: 2.5.14
    Site: https://selfdirectforum.com/forum/

    #187667

    In reply to: PHP Fatal Error

    Taim786
    Participant

    Hi Gunilla,

    If you have still not resolved your problem, you need to edit your wp-config.php file which should be located in the root of your WordPress installation. You need to insert below mention code at the end of the file and then this error will disappear.

    define( ‘WP_MEMORY_LIMIT’, ‘256M’ );

    Source: https://www.webxen.com/kb/wordpress-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted/

    #187664
    kwerri
    Participant

    I have a plugin called myCred which allows me to add a shortcode to a post so that anyone looking at that post will be allowed to click on a link to add points.

    I am trying to figure out where in bbPress I will add this shortcode so that the link will appear for each post.

    I am guessing that I will need to create a specially named page and then add the shortcode, but I am not sure about how to create the page (i.e. what name to give it). Am I on the right track, and if not, can someone help?

    #187659
    #187647
    sarwarc
    Participant

    Thanks for finding the solution. Where do I add the code for menu and forum to make the Profile show up in Menu?

    #187615
    jjaureguiberry
    Participant

    I’m trying to integrate buddypress-docs with bbpress forums; the intention is to have topics of discussion within an article/doc. Using buddypress-docs hook ‘bp_docs_after_doc_content’, I create a corresponding forum (if it doesn’t exist) and add a shortcode to display a topic creation form. If a topic exists and is selected, I redirect to the associated article, and display a single topic with:
    echo do_shortcode( '[bbp-single-topic id=' . $topic_id .']' );
    So far, so good, I don’t know if it is the right aproach, but it seems to work.
    The problem comes when I want to post a reply within the selected topic. $_REQUEST variables are used to detect and display the selected topic, but on single-topic the additional ‘bbp_redirect_to’ hidden field is added, causing to redirect and lose those variables. I commented the line where this field is added (bbpress/includes/common/template.php:1620) and it works the way I want, but don’t want to do that 🙂
    Any suggestions on how to work this around without messing around with the plugin’s code? Hope the issue is clear, thank you for any help you can provide and for taking the time to read this.

    Wordpress ver. 4.8.2
    BBPress ver. 2.5.14
    BuddyPress Docs ver. 1.9.4

    #187578
    froust
    Participant

    Found solution 😉

    I just added <?php bbp_form_topic_tags(); ?>to the input vvalue, so now it look’s like thisL:

    <input type="text" value="<?php bbp_form_topic_tags(); ?>" />

    Regards

    #187577
    froust
    Participant

    Hi

    When I editing some topic I don’t see tags in the input which I entered, can we call them via some PHP code?
    Also screenshot: http://prntscr.com/gvpn8k

    Best Regards, and also I want to say that I like minimalism of this plugin 🙂

    Regards

    #187566
    mithrandir
    Participant

    I don’t want to change the colour using code as none of our participants would be able to do that

    The changes made in the CSS, are global and participants will not have to add any CSS code. Once the changes are applied they are visible to everyone across the website.

    #187565
    mithrandir
    Participant

    Not sure why its not working, seems to work on my end.

    I believe the cause of the issue is the wordpress theme your website is using.
    The best solution would be to contact the authors of the theme WPZOOM, and im sure they can find a quick solution.

    If not, you could try adding the CSS once more, the following should work:

    #bbpress-forums div.bbp-topic-content p a, #bbpress-forums div.bbp-reply-content p a{
    	background: none;
    	color: black !important;
            position:relative !important;
     	display:inline-block !important;
            visibility: visible !important;
    }

    In truth it is difficult to address any styling issues without being able to see the website, if you can not get in touch with the authors of the theme I could try my best to find a solution.

    #187563
    janallsopp
    Participant

    Thanks @mithrandir786 there are no plugins to alter the appearance of bbPress. And the CSS didn’t work. What else can I try? I don’t want to change the colour using code as none of our participants would be able to do that. Unless there is a visual editor?

    Thanks,
    Jan

    #187552
    mithrandir
    Participant

    Appears to be a css issue, are you using any plugins to modify the appearance of bbPress ?

    The following css should fix this

    .bbp-body .hentry p a{
    	color:#3f3f3f !important;
    	
    }

    you could change the color for the link to one of your preference by modifying the color property.

    If you are using wordpress version 4.7 and above, To add the css, in the WordPress dashboard navigate to:
    Appearance>customize>Additional css

    copy and paste the code and save changes.

    #187547
    MakarkinPRO
    Participant

    Found another plugin

    <?php
    /*
    Plugin Name: .html in url
    Plugin URI: http://www.witsolution.in/
    Description: Adds .html to pages.
    Author: witsolution
    Version: 1.0
    Author URI: http://www.witsolution.in/
    */
    
    add_action('init', 'witsolution_page_permalink', -1);
    register_activation_hook(__FILE__, 'witsolution_active');
    register_deactivation_hook(__FILE__, 'witsolution_deactive');
    
    function witsolution_page_permalink() {
    	global $wp_rewrite;
     if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
    		$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
     }
    }
    add_filter('user_trailingslashit', 'witsolution_page_slash',66,2);
    function witsolution_page_slash($string, $type){
       global $wp_rewrite;
    	if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){
    		return untrailingslashit($string);
      }else{
       return $string;
      }
    }
    
    function witsolution_active() {
    	global $wp_rewrite;
    	if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
    		$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
     }
      $wp_rewrite->flush_rules();
    }	
    	function witsolution_deactive() {
    		global $wp_rewrite;
    		$wp_rewrite->page_structure = str_replace(".html","",$wp_rewrite->page_structure);
    		$wp_rewrite->flush_rules();
    	}
    ?>

    for posts and pages its working fine. How to make it work for topic and forums for BbPRESS?

    #187538
    mithrandir
    Participant

    @robin-w, @johnjamesjacoby

    Thankyou very much for replying,

    I am currently working on a solution, That was my initial observation aswell, regarding hard coded values. Users will be able to opt-in or opt-out by submitting a checkbox input field. I was hoping I could post back soon, once I had accomplished a (not so embarrassing) solution.

    Thanking you again for your help, and for all your exceptionally amazing work with bbPress.

    #187537
    mithrandir
    Participant

    Yes that would be the best solution, depending on their support for theme customization. I have extracted(just for testing purposes) the CSS from there live demo site for ‘discoverypro’, and can confirm it is the cause of the bbPress styling issues.

    Users names from under their profile pictures trail off the right side of the screens

    fix:

    .bbp-body .bbp-topic-meta .bbp-author-name{
    	display:block;
    }

    when reading posts and replies within topics, all the users profile pics squash themselves all together at the top left hand-side of the screen.

    *I cannot recreate this issue as it is specific to your website, however if you could provide a link to your forums/website it would be possible to fix the issue.

    #187496

    This won’t be super easy, unfortunately. Users would need to opt-in or opt-out of being anonymous (either in their profiles, or in their individual posts) and then there are a bunch of places the user account would need to be overloaded with some anonymous’esque object with hardcoded values.

    So, 3 things are necessary:

    * Profile integration
    * Topic/Reply integration
    * Per-post User override

    It’s possible, but will take a few development hours to achieve.

    robbinwwok
    Participant

    WP version: 4.8.2
    bbPress version: 2.5.14
    Website: courses.wisdomwayofknowing.org

    Even working with an experienced developer, we are at a dead-end with trying to get working a function essential to our online courses (without ditching all of the plug-ins and having a platform built from the ground-up), that has to do with group registration of group leaders without the leaders having to pay for all of the seats for their students; those teachers (or admin) being able to set them up on the back-end as a group leader and then be able to assign anyone to them as a group leader; and the group leader/admin having the ability to set up private forums for each group leaders when they need a private forum. And, finally, that this same group leader will be able to have several ongoing but separate groups of students who will be taking the course with him/her.

    I’ve also sent this query as a support ticket to WisdmLabs (the group registration plug-in we purchased that, at this point, doesn’t have the features we need), and LearnDash as the course platform.

    What we need from this query: any possible solutions or help pinpointing where we need to look next. Any help/ideas you can provide will be GREATly appreciated. And time is important as we’ve already had queries for group registrations with the ability to host private forum discussions and we can’t help them until this issue is solved.

    Here’s a list of functions/features we need and the issues we’ve encountered.
    • Group leaders to be able to register singly (we want to offer the course to leaders at no cost or low cost), and then when their students register, to be able to assign the students to them as a group leader.
    • Group leader to have the ability to create and moderate private discussion forums with their students. (They would have access to the general course forums that are visible to anyone who has registered for the course, but the leader, at his/her discretion, could create a private forum area for only those registered students whom they “allow” in.)
    • Students to be able to register for a course as a single user (we can offer these users, who have indicated who their group leader is, a coupon code provided to the group leader to share with the students who will be taking the course with them). Currently, there is no way on the back-end to assign students who register singly to a particular group leader. And, there is no way currently for that group leader to set up private forums for their students.

    The way the current group registration plug-in works we have installed (by WisdmLabs), the group leader has to purchase all of the “seats” both for themselves and for any student they want to register. Yet, NONE of the teachers who are currently interested in our first course are in a position to purchase on behalf of their students.

    How can we allow teachers/group leaders to:
    • register as any other single user would (or have a portal for this because someone has created a plug-in!)
    • have us set up (or the group leader set up) that leader as a course group leader on the back-end
    assign students who have registered using a distinctive coupon to a group leader
    • allow group leaders (or admins) to create a private course forum for any group that they are leading?

    What are we missing? Many thanks for any insight you can provide!

    Robbin Whittington
    robbin@wisdomwayofknowing.org

    #187482
    pmbordeaux
    Participant

    Many thank’s

    The solution was to put the permalinks into “name of the article”

    Now I have to change the shortcode [bbp-topic-index]

    #187469
    mithrandir
    Participant

    The problem is most likely not specific to bbPress and is with your server settings or htacess. WordPress may not be able to generate or modify the .htaccess file for your website due to file permissions issues. It might help to delete the htaccess file, grant correct permissions and refresh permalinks which will generate a new htaccess file. Try to enable php error log in htaccess as well.

    # enable PHP error logging
    php_flag  log_errors on
    php_value error_log  /path/to/htdocs/PHP_errors.log

    Create a blank PHP_errors.log file in the directory specified in your .htaccess file and set its permissions to 777. Now refresh the page that’s giving the 500 error and check if that log file now contains an error(s).

Viewing 25 results - 4,826 through 4,850 (of 32,518 total)
Skip to toolbar