Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,501 through 1,525 (of 32,432 total)
  • Author
    Search Results
  • #222458

    In reply to: Forum url changes

    pawanahluwalia
    Participant

    Thanks!

    However, is_bbpress() only seems to be true if you are on the root forum page.

    How can I test for any forum page?

    I tried

    echo get_permalink();

    on a forum page, but it does not display anything. It does display it on the root forum page, but it does not match the root forum page permalink. It again shows the highest Forum ID permalink instead.

    Presumably the page is being created in code and is overwriting the content of the current forum page.

    Any further suggestions?

    #222455

    In reply to: Forum url changes

    Robin W
    Moderator

    I’d suspect that because each forum is not an real individual wordpress page (ie not in dashboard>pages) , then retrieving the page_link might well return a ‘virtual’ ID, and this might be the top forum – not proven, just a hunch.

    My initial suggestions would be that you try get_permalink instead of get_page_link() – this retrieves the full url of the current displayed page, and should in theory get you what you want.

    If you need the existing get_page_link() for your other pages, you could try wrapping it in an if… eg:

    if (is_bbpress()) {
    get_permalink etc.
    }
    else {
    get_page_link()
    }

    Let us know if that helps

    packzap
    Participant

    My server is showing this error repeatedly:
    “PHP Parse error: syntax error, unexpected ‘new’ (T_NEW) in /home/…/bb-settings.php on line 188”

    When I look at line 186 thru 190 of bb-settings.php, it shows this statement:

    // Setup the global database connection
    $bbdb_class = BB_DATABASE_CLASS;
    $bbdb =& new $bbdb_class( array(
    	'name' => BBDB_NAME,
    	'user' => BBDB_USER,

    I am trying to troubleshoot what it is about that line with the “new” statement that causes this parse/syntax error repeatedly by the server. Any thoughts are appreciated. Thank-you.

    #222425
    specstanza
    Participant

    Thank you so much @robin-w – changed the subscription to fav with bbp_get_topic_favoriters 🙂

    add_action('bbp_template_before_single_topic', 'show_bbp_sub');
    function show_bbp_sub() { 
    	$subscriptions = bbp_get_topic_favoriters(bbp_get_topic_id()) ;
    	$count = count($subscriptions) ;
    	echo 'number of users subscribed: '.$count;
    }

    Now I only have to look for a way to display my topics and sorted them by numbers of favs! Thanks to you I know there was some major changes with the 2.6 version.

    #222424
    Robin W
    Moderator

    I’ve just taken a look – the whole way subscriptions works was changed in 2.6

    this code works on my test site

    add_action('bbp_template_before_single_topic', 'show_bbp_sub');
    function show_bbp_sub() { 
    	$subscriptions = bbp_get_subscribers(bbp_get_topic_id()) ;
    	$count = count($subscriptions) ;
    	echo 'number of users subscribed: '.$count;
    }
    #222416
    specstanza
    Participant

    Hi @robin-w – thanks for your answer.
    Here it is – as I’m still learning PHP, I apologize if I did a terrible coding mistake.
    I tried some modifications here and there (return, echoing other stuff) but nothing did the trick.

    /* tried to hook the code in my template */
    add_action('bbp_template_before_single_topic', 'show_bbp_sub');
    function show_bbp_sub() { 
    /* end of it */ 
     /* Original lines from @babblebey */
    $topic = bbp_get_topic_id();
    $users = get_users() ;
    $countsub = 0; /* I guess it's echoing only this line */
    foreach ($users as $user) {
        $topicsub_listarray = get_usermeta ($user->id, 'wp__bbp_subscriptions', true) ;
        $topicsub_list = explode (',' , $topicsub_listarray) ;
        if (in_array ($topic , $topicsub_list))  $countsub++ ;
    }
    echo $countsub;
    }
    

    Thank you for your help and your patience.

    #222407
    Robin W
    Moderator

    can you post the complete code

    #222401
    r-a-y
    Participant

    Documentation is lacking. Your best bet is to dive into the code.

    bbp_insert_forum() to create a forum:
    https://github.com/bbpress/bbPress/blob/master/src/includes/forums/functions.php#L24

    bbp_insert_topic() to create a topic: https://github.com/bbpress/bbPress/blob/master/src/includes/topics/functions.php#L24

    For BuddyPress, look at the wp_bp_activity DB table with the component column set to groups. You could use BP_Activity_Activity::get() (https://github.com/buddypress/buddypress/blob/master/src/bp-activity/classes/class-bp-activity-activity.php#L380) to fetch activity items, but probably querying the DB is faster.

    The rest is up to you.

    #222398
    specstanza
    Participant

    Hi @babblebey & @robin-w , thank you both for your work on this matter.

    I’m trying to do the same on my Bbpress install (not online yet) in order to sort topic by number of “fav mentions”.

    I tried your last two codes but it returns “0” (I hooked them on bbp_template_before_single_topic and putted them in two separated functions).

    Does it still works for you? Did I get it all wrong?

    Thank you for your answer. 🙂

    #222379
    r-a-y
    Participant

    Is it correct to say that if the BuddyPress group exists with some posts, and I set up a new bbPress forum in the backend, the existing posts will appear in the bbPress forum?

    Depends what you mean by “some posts”. If the BuddyPress group was originally set up with bbPress integration as mentioned here: https://codex.buddypress.org/getting-started/installing-group-and-sitewide-forums/ (The B and C options only). And forum posts were created in those groups, then yes. You just need to disable BuddyPress and those forum posts should still be viewable.

    Otherwise, no. You are probably thinking of the BuddyPress group activity stream that uses Twitter-style status updates, which is not a forum.

    #222377
    Robin W
    Moderator

    just taken a quick look.

    yes it looks like it will show the sub forums of a forum ID you enter, but not the parent forums as well.

    I should say I’m not a bbpress author, and after a check of the code it is not an easy change to fix

    #222376
    Robin W
    Moderator

    the code is valid – I suspect you have a copy/paste issue – sometimes a ‘ becomes corrupted,

    Can you post exactly what you have in your file

    #222369
    linguabuddy
    Participant

    Looks like something may have changed as this code is now producing a fatal error.

    I used the second snippet to edit the reply emails but while the email send has been successfully modified (and is no longer bouncing), the user now gets a white screen…

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘my_bbp_no_reply_email’ not found or invalid function name in /home/customer/www/[domain]/public_html/wp-includes/class-wp-hook.php on line 287

    Has something been updated in the codex?

    #222324
    aliforty
    Participant

    I was familiar, just a brain freeze early on Monday 🙂

    But please let me know what arguments I should pass that would get the outcome I am hoping for. I was wanting for “\r \n” in TinyMCE to be replaced with <br /> tags. The WordPress database was not saving those escaped characters or at the very least wasn’t displaying them back. Eerything was being shown in one line. Teeny and TinyMCE is enabled.

    For the time being, I did find an alternative solution. Replaced the “\r \n” with <br /> for the posts and disabled the bbp_code_trick_reverse filter that was removing them later.

    function bbp_convert_reply_breaks_to_tags($output, $args, $post_content){
            $text = str_replace(array("\r\n", "\n", "\r"), "<br />", $post_content);
            return $text;
        }
    
      function bbp_convert_topic_and_forum_breaks_to_tags($post_content){
            $text = str_replace(array("\r\n", "\n", "\r"), "<br />", $post_content);
            return $text;
        }
    
     add_filter('bbp_new_reply_pre_content', array($this, 'bbp_convert_reply_breaks_to_tags'), 10, 3);
            add_filter('bbp_new_topic_pre_content', array($this, 'bbp_convert_topic_breaks_to_tags'), 10, 1);
            add_filter('bbp_new_forum_pre_content', array($this, 'bbp_convert_topic_and_forum_breaks_to_tags'), 10, 1);
            remove_filter('bbp_get_form_reply_content', 'bbp_code_trick_reverse');
            remove_filter('bbp_get_form_forum_content', 'bbp_code_trick_reverse');
            remove_filter('bbp_get_form_topic_content', 'bbp_code_trick_reverse');
    #222315
    Jan
    Participant

    This is my first post in this forum, so I apologize if this may sound like a no-brainer question.

    I went through a number of threats and understood that adding a topic tag cloud to a search page requires…

    (1) activation of the tagging feature in the forum settings (Done)
    (2) adding an HTML widget to the respective sidebar and (Done)
    (3) pasting the relevant HTML code snippet into the widget. (Open)

    Where can I find the HTML required for step number 3?

    Any advice is much appreciated.

    Thanks,
    Jan

    #222306
    Robin W
    Moderator

    apply_filters( 'bbp_get_the_content', $output, $args, $post_content );

    in

    bbpress 2.6.6\includes\common\template.php

    line 1940

    should do it

    #222261

    In reply to: Updatable Post Date

    Back to Front
    Participant

    Yes you could use

    .bbp-reply-post-date {
        display: none;
    }

    to hide you bbpress reply post date.

    But to display the post modified date you would need to add this function in you child theme templates whereever you want to display, eg replace
    bbp_topic_post_date();
    with
    the_modified_date();
    in templates/content-single-topic-lead.php

    #222236

    In reply to: Customize Groups URL

    r-a-y
    Participant

    For the ‘forum’ and ‘topic’ slug in a BuddyPress groups URL, see: https://buddypress.trac.wordpress.org/ticket/3745#comment:13

    You cannot remove it, but you can potentially rename it via code.

    #222231

    In reply to: Customize Groups URL

    r-a-y
    Participant

    When you set up BuddyPress, you had to set up a WordPress page that is associated to Groups.

    Go to the admin dashboard and visit “Pages”. Next, find the Groups page and edit the slug for the page to dev and that will fix the issue for you.

    #222188

    Topic: Add emoticons

    in forum Troubleshooting
    Ricsca2
    Participant

    I migrated a forum from vbulletin but now the customized smileys do not appear but I only see their code such as the writing: cgrd: or: by2:, how can I connect their codes to the smileys that I upload in ftp?

    Thank

    #222187
    o2disegno
    Participant

    The footer of the page was broken when I enter any page of the forum but the rest of the page works perfectly, only when I enter the pages of the forum it broke. I use wpbakery to build the page.

    The only page of the forum that works well is the one that I created by placing the shortcode: https://dermomen.com/foros-dermomen/ the rest of the pages break the footer and show it in text.

    Image of the problem:
    Captura-de-pantalla-2021-07-25-213806

    Preguntas de los novatos

    I hope you can help me. Thanks.

    #222152
    lolataylor1
    Participant

    WordPress 5.8
    bbPress 2.6.6
    BuddyPress 9.0.0
    Astra Theme 3.6.5

    Help! I have read every forum post about creating new custom roles in bbPress, but it still isn’t working for me. The created role names are displaying on my Users page in my Admin dashboard, but the roles themselves are not working as intended. When I assign a user a forum role, it is adding it under the “Roles” [i.e., Subscriber (WP Role), Founder (bbPress Role)] and not “Forum Roles.” I tested the different user role settings and they, too, are not working.

    Am I missing something or doing something wrong? I’m new to bbPress and very frustrated after spending hours trying to get this to work.

    This is the code I have create and placed in my Code Snippet plugin. The forum is being added to a paid members only website, so the URL would not be useful.


    function authorready_add_new_roles( $bbp_roles ) {
    $bbp_roles['bbp_probation'] = array(
    'name' => 'Probation',
    'capabilities' => custom_capabilities( 'bbp_probation' )
    );

    $bbp_roles['bbp_subscriber'] = array(
    'name' => 'Subscriber',
    'capabilities' => custom_capabilities( 'bbp_subscriber' )
    );

    $bbp_roles['bbp_founder'] = array(
    'name' => 'Founder',
    'capabilities' => custom_capabilities( 'bbp_founder' )
    );

    $bbp_roles['bbp_leader'] = array(
    'name' => 'Group Leader',
    'capabilities' => custom_capabilities( 'bbp_leader' )
    );

    $bbp_roles['bbp_moderator'] = array(
    'name' => 'Moderator',
    'capabilities' => custom_capabilities( 'bbp_moderator' )
    );

    $bbp_roles['bbp_administrator'] = array(
    'name' => 'Administrator',
    'capabilities' => custom_capabilities( 'bbp_administrator' )
    );

    return $bbp_roles;
    }

    add_filter( 'bbp_get_dynamic_roles', 'authorready_add_new_roles', 1 );

    function authorready_add_role_caps_filter( $caps, $role )
    {
    /* Only filter for roles we are interested in! */
    if( $role == 'bbp_probation' )
    $caps = custom_capabilities( $role );

    if( $role == 'bbp_subscriber' )
    $caps = custom_capabilities( $role );

    if( $role == 'bbp_founder' )
    $caps = custom_capabilities( $role );

    if( $role == 'bbp_leader' )
    $caps = custom_capabilities( $role );

    if( $role == 'bbp_moderator' )
    $caps = custom_capabilities( $role );

    if( $role == 'bbp_administrator' )
    $caps = custom_capabilities( $role );

    return $caps;
    }

    add_filter( 'bbp_get_caps_for_role', 'authorready_add_role_caps_filter', 10, 2 );

    function custom_capabilities( $role )
    {
    switch ( $role )
    {

    /* Capabilities for 'probation' role */
    case 'bbp_probation':
    return array(
    // Primary caps
    'spectate' => true,
    'participate' => false,
    'moderate' => false,
    'throttle' => false,
    'view_trash' => false,

    // Forum caps
    'publish_forums' => false,
    'edit_forums' => false,
    'edit_others_forums' => false,
    'delete_forums' => false,
    'delete_others_forums' => false,
    'read_private_forums' => false,
    'read_hidden_forums' => false,

    // Topic caps
    'publish_topics' => false,
    'edit_topics' => false,
    'edit_others_topics' => false,
    'delete_topics' => false,
    'delete_others_topics' => false,
    'read_private_topics' => false,

    // Reply caps
    'publish_replies' => false,
    'edit_replies' => false,
    'edit_others_replies' => false,
    'delete_replies' => false,
    'delete_others_replies' => false,
    'read_private_replies' => false,

    // Topic tag caps
    'manage_topic_tags' => false,
    'edit_topic_tags' => false,
    'delete_topic_tags' => false,
    'assign_topic_tags' => false,
    );

    /* Capabilities for 'subscriber' role */
    case 'bbp_subscriber':
    return array(
    // Primary caps
    'spectate' => true,
    'participate' => true,
    'moderate' => false,
    'throttle' => false,
    'view_trash' => false,

    // Forum caps
    'publish_forums' => false,
    'edit_forums' => false,
    'edit_others_forums' => false,
    'delete_forums' => false,
    'delete_others_forums' => false,
    'read_private_forums' => true,
    'read_hidden_forums' => false,

    // Topic caps
    'publish_topics' => false,
    'edit_topics' => false,
    'edit_others_topics' => false,
    'delete_topics' => false,
    'delete_others_topics' => false,
    'read_private_topics' => true,

    // Reply caps
    'publish_replies' => true,
    'edit_replies' => true,
    'edit_others_replies' => false,
    'delete_replies' => true,
    'delete_others_replies' => false,
    'read_private_replies' => true,

    // Topic tag caps
    'manage_topic_tags' => false,
    'edit_topic_tags' => false,
    'delete_topic_tags' => false,
    'assign_topic_tags' => false,
    );

    /* Capabilities for 'founder' role */
    case 'bbp_founder':
    return array(
    // Primary caps
    'spectate' => true,
    'participate' => true,
    'moderate' => false,
    'throttle' => false,
    'view_trash' => false,

    // Forum caps
    'publish_forums' => false,
    'edit_forums' => false,
    'edit_others_forums' => false,
    'delete_forums' => false,
    'delete_others_forums' => false,
    'read_private_forums' => true,
    'read_hidden_forums' => false,

    // Topic caps
    'publish_topics' => false,
    'edit_topics' => false,
    'edit_others_topics' => false,
    'delete_topics' => false,
    'delete_others_topics' => false,
    'read_private_topics' => true,

    // Reply caps
    'publish_replies' => true,
    'edit_replies' => true,
    'edit_others_replies' => false,
    'delete_replies' => true,
    'delete_others_replies' => false,
    'read_private_replies' => true,

    // Topic tag caps
    'manage_topic_tags' => false,
    'edit_topic_tags' => false,
    'delete_topic_tags' => false,
    'assign_topic_tags' => false,
    );

    /* Capabilities for 'group leader' role */
    case 'bbp_leader':
    return array(
    // Primary caps
    'spectate' => true,
    'participate' => true,
    'moderate' => true,
    'throttle' => false,
    'view_trash' => false,

    // Forum caps
    'publish_forums' => false,
    'edit_forums' => false,
    'edit_others_forums' => false,
    'delete_forums' => false,
    'delete_others_forums' => false,
    'read_private_forums' => true,
    'read_hidden_forums' => false,

    // Topic caps
    'publish_topics' => false,
    'edit_topics' => false,
    'edit_others_topics' => false,
    'delete_topics' => false,
    'delete_others_topics' => false,
    'read_private_topics' => true,

    // Reply caps
    'publish_replies' => true,
    'edit_replies' => true,
    'edit_others_replies' => true,
    'delete_replies' => true,
    'delete_others_replies' => true,
    'read_private_replies' => true,

    // Topic tag caps
    'manage_topic_tags' => false,
    'edit_topic_tags' => false,
    'delete_topic_tags' => false,
    'assign_topic_tags' => true,
    );

    /* Capabilities for 'moderator' role */
    case 'bbp_moderator':
    return array(
    // Primary caps
    'spectate' => true,
    'participate' => true,
    'moderate' => true,
    'throttle' => true,
    'view_trash' => true,

    // Forum caps
    'publish_forums' => false,
    'edit_forums' => false,
    'edit_others_forums' => false,
    'delete_forums' => false,
    'delete_others_forums' => false,
    'read_private_forums' => true,
    'read_hidden_forums' => false,

    // Topic caps
    'publish_topics' => true,
    'edit_topics' => true,
    'edit_others_topics' => false,
    'delete_topics' => false,
    'delete_others_topics' => false,
    'read_private_topics' => true,

    // Reply caps
    'publish_replies' => true,
    'edit_replies' => true,
    'edit_others_replies' => false,
    'delete_replies' => true,
    'delete_others_replies' => true,
    'read_private_replies' => true,

    // Topic tag caps
    'manage_topic_tags' => false,
    'edit_topic_tags' => true,
    'delete_topic_tags' => true,
    'assign_topic_tags' => true,
    );

    /* Capabilities for 'administrator' role */
    case 'bbp_administrator':
    return array(
    // Primary caps
    'spectate' => true,
    'participate' => true,
    'moderate' => true,
    'throttle' => true,
    'view_trash' => true,

    // Forum caps
    'keep_gate' => true,
    'publish_forums' => true,
    'edit_forums' => true,
    'edit_others_forums' => true,
    'delete_forums' => true,
    'delete_others_forums' => true,
    'read_private_forums' => true,
    'read_hidden_forums' => true,

    // Topic caps
    'publish_topics' => true,
    'edit_topics' => true,
    'edit_others_topics' => true,
    'delete_topics' => true,
    'delete_others_topics' => true,
    'read_private_topics' => true,

    // Reply caps
    'publish_replies' => true,
    'edit_replies' => true,
    'edit_others_replies' => true,
    'delete_replies' => true,
    'delete_others_replies' => true,
    'read_private_replies' => true,

    // Topic tag caps
    'manage_topic_tags' => true,
    'edit_topic_tags' => true,
    'delete_topic_tags' => true,
    'assign_topic_tags' => true,
    );

    break;

    default :
    return $role;
    }
    }

    #222151

    In reply to: Help with Forum Roles

    mairag
    Participant

    Thank you Robin.

    I did the change but didn’t solve the issue, let’s see if OP had more luck.

    This is my updated code for the new role Crochetera.

    // bbPress custom role
    
    add_action ('wp_loaded' , 'load_new_roles') ;
    function load_new_roles () {
    	add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );
    	add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
    }
     
    function add_new_roles( $bbp_roles ){
        /* Add a role called crochetera */
        $bbp_roles['bbp_crochetera'] = array(
            'name' => 'Crochetera',
            'capabilities' => custom_capabilities( 'bbp_crochetera' )
            );
     
        return $bbp_roles;
    }
     
    function add_role_caps_filter( $caps, $role ) {
        /* Only filter for roles we are interested in! */
        if( $role == 'bbp_crochetera' )
            $caps = custom_capabilities( $role );
     
        return $caps;
    }
     
    function custom_capabilities( $role ){
        switch ( $role ) {
     
            /* Capabilities for 'crochetera' role */
            case 'bbp_crochetera':
                return array(
                    // Primary caps
                    'spectate'              => true,
                    'participate'           => true,
                    'moderate'              => false,
                    'throttle'              => false,
                    'view_trash'            => false,
     
                    // Forum caps
                    'publish_forums'        => false,
                    'edit_forums'           => false,
                    'edit_others_forums'    => false,
                    'delete_forums'         => false,
                    'delete_others_forums'  => false,
                    'read_private_forums'   => false,
                    'read_hidden_forums'    => false,
     
                    // Topic caps
                    'publish_topics'        => false,
                    'edit_topics'           => false,
                    'edit_others_topics'    => false,
                    'delete_topics'         => false,
                    'delete_others_topics'  => false,
                    'read_private_topics'   => false,
     
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => false,
                    'delete_replies'        => false,
                    'delete_others_replies' => false,
                    'read_private_replies'  => true,
     
                    // Topic tag caps
                    'manage_topic_tags'     => false,
                    'edit_topic_tags'       => false,
                    'delete_topic_tags'     => false,
                    'assign_topic_tags'     => false,
                );
     
                break;
     
            default :
                return $role;
        }
    }
    myblackf150
    Participant

    Hello,

    I copied the code forms-topic to create a very simple form for use in only one forum.
    How I may please pre-select the forum from the drop-down that selects which forum to post by default? I’d assume it would require the forum ID but I do not know how to make it select to that forum by default.

    Thank you for any assistance.

    #222145

    In reply to: Help with Forum Roles

    Robin W
    Moderator

    If that is not clear, post your code and I’ll give back the correct version.

Viewing 25 results - 1,501 through 1,525 (of 32,432 total)
Skip to toolbar