Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,401 through 1,425 (of 32,467 total)
  • Author
    Search Results
  • #224093
    Robin W
    Moderator

    @joel-mohanraj
    find
    wp-content/plugins/bbpress/templates/default/bbpress/loop-single-forum.php

    transfer this to your pc and edit

    so you will want to take the link out of line 34

    <a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>"><?php bbp_forum_title(); ?></a>

    and save

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

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

    Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/loop-single-forum.php

    bbPress will now use this template instead of the original

    amending the freshness will require you to amend the bbp_get_forum_freshness_link function. if you are familiar with filters you can use the filter on line 585 of \includes\forums and a str_replace to take out the link

    #224069
    TreeTrail
    Participant

    Robin W,

    Thank you very much for volunteering some thoughts. Especially that you indicating that changes this year haven’t affected the bbp_add_user_forum_subscription function. And it appears that groups_join_group is a BuddyPress function. Your reminder to turn on the debug was priceless. There was only one, unrelated notice.

    I rechecked the Developer’s (Harsha Vetkatesh’s) code online and realized that he had added an updated version! At https://gist.github.com/greathmaster/e67f1ae0feb28c9ab3521b404c8e0544. I added it into a staging copy and it threw a specific error. I’m going to see if I can contact him.

    Thanks again for the Forum. Our trail club uses it very frequently.

    Best Regards,
    ~April

    #224044
    lumisdev
    Participant

    Hello everyone!

    I’m a new user of bbpress and I’m looking for a way for logged in users to subscribe/unsubscribe to all forums by clicking a button.

    I’ve managed to do it by myself, but I’d like to know if there is an easier way to do it.

    Here is the code in my loop-forums.php file:

    
    <?php
    
    /**
     * Forums Loop
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    // Exit if accessed directly
    defined('ABSPATH') || exit;
    
    do_action('bbp_template_before_forums_loop'); ?>
    
    <?php
    $current_user = get_userdata(get_current_user_id());
    
    if (isset($current_user) && $current_user->ID > 0) :
      $user_subscribed_forum_ids = bbp_get_user_subscribed_forum_ids($current_user->ID);
      $forum_ids_list = array();
    
      while (bbp_forums()) : bbp_the_forum();
        if (bbp_get_forum_type() === 'category') :
    
          foreach (bbp_forum_get_subforums() as $subforum) :
            $forum_ids_list[] = $subforum->ID;
          endforeach;
        else :
          $forum_ids_list[] = bbp_get_forum_id();
        endif;
      endwhile;
    
      $check = sizeof($forum_ids_list) === sizeof($user_subscribed_forum_ids);
      $bbp_action = $check ? "bbp_unsubscribe" : 'bbp_subscribe';
      $label = $check ? "Unsubscribe of all forums" : "Subscribe of all forums";
      $label .= bbp_get_forum_type() === 'category' ? " of this category" : "";
    
      if (isset($_POST) && $_POST['action']) :
        foreach ($forum_ids_list as $forum_id) :
          $q_args = array(
            'action'      => $bbp_action,
            'object_id'   => $forum_id,
            'object_type' => 'post'
          );
    
          $permalink = bbp_get_forum_permalink($forum_id);
          $wp_nonce_url = esc_url(wp_nonce_url(add_query_arg($q_args), 'toggle-subscription_' . $forum_id));
          $wp_nonce_url = substr($wp_nonce_url, strlen('/'));
          $url = html_entity_decode($permalink . $wp_nonce_url);
    
          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_COOKIE, LOGGED_IN_COOKIE . '=' . $_COOKIE[LOGGED_IN_COOKIE]);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
          $response = curl_exec($ch);
          curl_close($ch);
        endforeach;
    
        $user_subscribed_forum_ids = bbp_get_user_subscribed_forum_ids($current_user->ID);
        $check = sizeof($forum_ids_list) === sizeof($user_subscribed_forum_ids);
        $bbp_action = $check ? "bbp_unsubscribe" : 'bbp_subscribe';
        $label = $check ? "Unsubscribe of all forums" : "Subscribe of all forums";
        $label .= bbp_get_forum_type() === 'category' ? " of this category" : "";
      endif; // isset($_POST) && $_POST['action']
    endif; // isset($current_user) && $current_user->ID > 0
    ?>
    
    <?php if (isset($_POST) && $_POST['action']) : ?>
      <script id="prevent-form-resubmission-when-page-is-refreshed" type="text/javascript">
        // source: https://stackoverflow.com/questions/6320113/how-to-prevent-form-resubmission-when-page-is-refreshed-f5-ctrlr
        if (window.history.replaceState) {
          window.history.replaceState(null, null, window.location.href);
          document.getElementById('prevent-form-resubmission-when-page-is-refreshed').remove();
        }
      </script>
    <?php endif; ?>
    
    <?php if (isset($current_user) && $current_user->ID > 0 && !bbp_is_single_user()) : ?>
      <form action="" method="POST">
        <input type="hidden" name="action" value="<?= $bbp_action ?>">
        <button type="submit" style="color: black;"><?= __($label, 'ls') ?></button>
      </form>
    <?php endif; ?>
    
    <table id="forums-list-<?php bbp_forum_id(); ?>" class="table table-bordered forums-list">
    
      <thead>
        <tr>
    
          <th class="forum-title-column">
            <?php esc_html_e('Forum', 'ls'); ?>
          </th>
    
          <th class="posts-count-column">
            <?php bbp_show_lead_topic() ? esc_html_e('Replies', 'ls') : esc_html_e('Posts', 'ls'); ?>
          </th>
    
          <th class="last-post-column">
            <?php esc_html_e('Last Post', 'ls'); ?>
          </th>
    
        </tr>
      </thead>
    
      <tbody>
    
        <?php while (bbp_forums()) : bbp_the_forum(); ?>
          <?php bbp_get_template_part('loop', 'single-forum'); ?>
        <?php endwhile; ?>
    
      </tbody>
    
    </table>
    
    <?php do_action('bbp_template_after_forums_loop');
    
    #224022
    Robin W
    Moderator

    ps – I presume you have a function

    groups_join_group but have not shown it for simplicity ?

    #224021
    Robin W
    Moderator

    just looked at this – sorry, as you say I don’t get to every item, and this is bespoke code which means something to someone, but without a heavy investment of time, it is hard to debug why it is not working ๐Ÿ™‚

    the function bbp_add_user_forum_subscription is still valid, and should work fine, so the actual change to the way bbpress works should not affect it.

    I have little knowledge of buddypress, so I cannot say whether that code is still valid.

    Have you turned debugging on ? and is it showing anything ?

    #223997
    sangcoats
    Participant

    I can use the same theme for topics as well, as in this case:
    https://www.aqazero.com/forums/forum/acquario-acquariofilia-%f0%9f%8c%8a%f0%9f%90%a0-aqa0-%f0%9f%90%9f%f0%9f%8c%bf/

    Unfortunately, however, if I open the question (post) the theme is not inherited
    https://www.aqazero.com/forums/topic/prova-topic/ friday night funkin

    Is there a shortcodes to display the question (post) and the area to reply (reply form)?

    Thanks in advance for your answers..

    I have the same issue here. Did you find a fix for it, by any chance?

    #223996

    Topic: Thumbs up and down

    in forum Plugins
    gnfb
    Participant

    I am desperately searching for a forum that has the ability to rate threads. The forum will be for promo codes and I want users to have the abilty to ad a yes working or no working comment by way of thumbs. so if one had 10 down thumbs and no up thumbs dont bother!
    Is there such an abilty by way of a plugin? I cant aford the hundreds to have code written to do the job (sorry coders)

    #223994
    Robin W
    Moderator

    Just had a thought and dug in the code further, the duplicate check doesn’t apply to those roles/users that can ‘throttle’

    // No duplicate checks for those who can throttle
    	if ( user_can( (int) $r['post_author'], 'throttle' ) ) {
    		return true;
    	}

    bbPress User Roles and Capabilities

    so default Keymaster and Moderator can post duplicates

    #223988
    Robin W
    Moderator

    I am not a bbpress author, just someone who helps out here.

    Every website is unique, and this doesn’t happen on my test site – I have not seen this reported elsewhere as an issue, and the code has a duplicate function check in it.

    line 307 of includes/replies/functions

    /** Reply Duplicate *******************************************************/
    
    	if ( ! bbp_check_for_duplicate( array( 'post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) ) {
    		bbp_add_error( 'bbp_reply_duplicate', __( '<strong>Error</strong>: Duplicate reply detected; it looks as though you’ve already said that.', 'bbpress' ) );
    	}

    I am not able to say why you are getting this.

    #223948
    Robin W
    Moderator

    ok, without knowing what is determining the order, it is hard to give you code to correct.

    I’d suggest you play with publish dates of the stickies and ant replies to them to see if you can work out the issue, then come back and I’ll see if I can help further

    #223935
    Robin W
    Moderator

    line 322 of \includes\topics\template.php has the function I think

    you’d use a filter to add an ‘order by’ probably using the parse args on line 330

    so

    add_filter ('bbp_before_add_sticky_topics_parse_args' , 'your_function') ;
    
    function your_function ($r) {
    //add the order you want to sort
    $r['order_by'] = etc......
    
    }
    

    Sorry don’t have time to look at this evening, but come back if you need further help

    #223934
    rngeer
    Participant

    Nada, just going to explain the nature of it to them and dig around later for a code hack if there is one. Thank you so much for the help.

    #223920
    rngeer
    Participant

    Hello, this is a request I have to force the order of two sticky posts so that they don’t change when a new comment is added.

    Sticky 1
    Sticky 2

    Sticky 2 will move above Sticky one with a new comment, and vice-versa.

    Any way in the code to force that sticky order to stay the same all the time.

    Thanks in advance.

    #223902
    Robin W
    Moderator

    untested, but this should work

    add_filter( 'bbp_get_reply_author_display_name' , 'rew_reply_change_to_first_name', 10 , 2 ) ;
    
    function rew_reply_change_to_first_name ($author_name, $reply_id) {
    	// Get the author ID
    	$author_id = bbp_get_reply_author_id( $reply_id );
    	$user = get_userdata($author_id); 
    	$first_name = $user->user_firstname;
    return $first_name ;
    }
    
    add_filter( 'bbp_get_topic_author_display_name' , 'rew_topic_change_to_first_name', 10 , 2 ) ;
    
    function rew_topic_change_to_first_name ($author_name, $topic_id) {
    	// Get the author ID
    	$author_id = bbp_get_topic_author_id( $topic_id );
    	$user = get_userdata($author_id); 
    	$first_name = $user->user_firstname;
    return $first_name ;
    }

    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

    #223839
    angelfire4xx
    Participant

    It seems to be a real struggle to create a new custom role for bbpress ๐Ÿ™
    I’ve been trying out all the different solutions I’ve found online but nothing is working.
    All I want to do is to be able to assign the role of Naturopath to some of my forum participants. They would have the same capabilities as the Participant role, just have Naturopath instead of Participant showing under their name in the Forum. The rest of the Participants can continue to show “Participant”.
    Can anyone here maybe write the code for me as a paid job?
    I have WP 5.8.1
    bPress 2.6.6

    #223771

    In reply to: Add Custom User Roles

    angelfire4xx
    Participant

    Great tip about code snippets plugin, I didn’t know about that one, thanks!

    Sadly the user is still showing up in bbpress as Participant. Although I was able to save the user with a Naturopath role in WP.

    #223770

    In reply to: Add Custom User Roles

    Robin W
    Moderator

    ok, I think it was just loading in the wrong place, try

    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 naturopath */
    $bbp_roles['bbp_naturopath'] = array(
    'name' =>'Naturopath',
    'capabilities' =>custom_capabilities( 'bbp_naturopath' )
    );
    
    return $bbp_roles;
    }
    
    function add_role_caps_filter( $caps, $role )
    {
    /* Only filter for roles we are interested in! */
    if( $role == 'bbp_naturopath' )
    $caps = custom_capabilities( $role );
    
    return $caps;
    }
    
    function custom_capabilities( $role )
    {
    switch ( $role )
    {
    
    /* Capabilities for 'naturopath' role */
    case 'bbp_naturopath':
    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' => 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' => 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' => true,
    );
    
    break;
    
    default :
    return $role;
    }
    }

    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

    #223767

    In reply to: Add Custom User Roles

    angelfire4xx
    Participant

    Thanks Robin, I did search and replace tutor > Naturopath and pasted the code at the end of functions.php. I would love to say it worked but…

    Naturopath appeared as a forum role selection in the dropdown for each WP User. However when Naturopath was selected for the user and then saved, WP only displayed Role = “No role for this user”, and Capabilities = bbp_Naturopath.

    When I tried a test post as that user, BBPress described me as a participant.
    So, not there yet, but your help is appreciated ๐Ÿ™‚
    Linda

    (PS: I’m looking for the Naturopath role to have the same capabilities as Participant.)

    #223766

    In reply to: Add Custom User Roles

    Robin W
    Moderator
    //code to add tutor 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 tutor */
    $bbp_roles['bbp_tutor'] = array(
    'name' =>'Tutor',
    'capabilities' =>custom_capabilities( 'bbp_tutor' )
    );
    
    return $bbp_roles;
    }
    
    function add_role_caps_filter( $caps, $role )
    {
    /* Only filter for roles we are interested in! */
    if( $role == 'bbp_tutor' )
    $caps = custom_capabilities( $role );
    
    return $caps;
    }
    
    function custom_capabilities( $role )
    {
    switch ( $role )
    {
    
    /* Capabilities for 'tutor' role */
    case 'bbp_tutor':
    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' => 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' => 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' => true,
    );
    
    break;
    
    default :
    return $role;
    }
    }
    Chuckie
    Participant

    @wendylady, also, if you install the “Advanced Editor Tools” plugin you can get your TinyMCE toolbar to show the menu bar. I just tried it. This menu bar has the “Restore last draft” on it.

    But I have not added any code to include the “restoredraft” button on the toolbar itself.

    But as previously mentioned, the autosave is defaulting to 30 seconds.

    Chuckie
    Participant

    Hi @wendylady

    Thanks for trying the plugin! According to the TinyMCE documentation for autosave it simply states:

    This plugin gives the user a warning if they made modifications to the content within an editor instance but didn’t submit the changes.

    I notice there is an option autosave_interval:

    This option enables you to specify the time the editor should wait between taking snapshots of the current content and saving them to local storage. The syntax is to append the letter s to the end of a number value. For example, “30s” for 30 seconds.

    According to the documentation the default is 30 seconds. Since i do not specify this option in my plugin it must be using this default of 30 seconds.

    If you don’t mind, could you also re-produce your query in the support forum for the plugin:

    https://wordpress.org/support/plugin/add-autosave-fullscreen-to-tinymce/

    ?

    And I can add the same response there.

    Does this help?

    #223700

    In reply to: Forum Display

    Robin W
    Moderator

    sorry, copied the wrong link

    it should be

    [bbp-single-forum id=$forum_id]

    all the shortcodes are here

    Shortcodes

    #223699

    In reply to: Forum Display

    cryptobeya
    Participant

    Thank you. I tried that, however it displays the “create new topic” form and not the forum list. Is that shortcode correct?

    Coin Forums
    Create New Topic in โ€œCoin Forumโ€
    Your account has the ability to post unrestricted HTML content.
    Topic Title (Maximum Length: 80):

    Topic Tags:

    Topic Type:

    #223696

    In reply to: Forum Display

    cryptobeya
    Participant

    Thank you, that makes sense. When I add the short code to each page, you say $forum Id = the category. Where can I find the forum Id for the category? Is that just the name of the category?

    The name of my category id Coin Forum. What should go in the $forum_id space below?

    [bbp-topic-form forum_id=$forum_id]

    #223676
    MrsJessicaSimpson
    Participant
    add_filter( 'bbp_get_view_query_args', 'rew_limit') ;
    
    function rew_limit ($args) {
    $args['posts_per_page'] = -1 ;
    $args['posts_per_page'] = 10 ;
    return $args ;
    }

    Following this, and looking at it: then a bracket ‘]’ might be missing where the (= 10) line is.
    Which could explain the unexpected T_FUNCTION error.

    Got this code running on my site, (in the functions.php file), and it seems to work.

    Happy-hacking.

Viewing 25 results - 1,401 through 1,425 (of 32,467 total)
Skip to toolbar