重定向 bbPress 個人資料連結到自定義連結地址,如主題自帶的使用者中心。

正在檢視 4 個帖子:1-4 (共 4 個帖子)
  • 作者
    帖子
  • 小新
    • 文章數量: 354
    @xiaoxin
    樓主

    做客戶 bbPress 主題定製單,其中一個需求就是因為使用的主題已經有自帶的比較好的使用者中心現在需要重定向 bbPress 個人資料連結到自定義連結地址到的主題使用者中心。

    我可以用這個簡單的程式碼來完成重定向:

    add_filter( 'bbp_pre_get_user_profile_url', function() {
    	return get_bloginfo('url').'/profile';
    });

    修改其中的 /profile 地址即可。

    很簡單,真的!

    您還可以透過以下操作更改收藏夾和訂閱的預設網址:

    
    // Replace the default link for the favorites
    add_filter( 'bbp_get_favorites_permalink', function() {
    	return get_bloginfo('url').'/profile/forum-favorites';
    });
    
    // Replace the default link for subscriptions
    add_filter( 'bbp_get_subscriptions_permalink', function() {
    	return get_bloginfo('url').'/profile/forum-subscriptions';
    });
    詩語
    管理員
    • 文章數量: 5,925
    @feibisi
    此回覆已被標記為私有,🔒 僅樓主及管理員可見。
    詩語
    管理員
    • 文章數量: 5,925
    @feibisi

    給 bbPress 新增全域性搜尋框:

    //display bbPress search form above sinle topics and forums
    function rk_bbp_search_form(){
     
        if ( bbp_allow_search()) {
            ?>
            <div class="bbp-search-form">
     
                <?php bbp_get_template_part( 'form', 'search' ); ?>
     
            </div>
            <?php
        }
    }
     
    add_action( 'bbp_template_before_single_forum', 'rk_bbp_search_form' );
    add_action( 'bbp_template_before_single_topic', 'rk_bbp_search_form' );

    非常棒的方法。

    詩語
    管理員
    • 文章數量: 5,925
    @feibisi

    隱藏 bbPress 的全部側邊欄

    
    /* Hide SideBar in bbPress Profiles and Topics*/
    function disable_all_widgets( $sidebars_widgets ) {       
        if ( function_exists('is_bbpress') ) {
            if (is_bbpress()) {
                $sidebars_widgets = array(false);
                remove_all_actions('bp_register_widgets');
                unregister_sidebar( 'bp_core_widgets' );
            }
        }
        return $sidebars_widgets;
    }
    
    add_filter('sidebars_widgets', 'disable_all_widgets', 1, 1);
正在檢視 4 個帖子:1-4 (共 4 個帖子)
  • 哎呀,回覆話題必需登入。

話題資訊

  • 當前位於:bbPress
  • 3 條回覆
  • 2 個參與人
  • 最後回覆:<a href="https://bbs.weixiaoduo.com/users/feibisi/" title=" 檢視詩語的個人資料" class="bbp-author-link"><span class="bbp-author-name"> 詩語</span></a>
  • 上次活動:<a href="https://bbs.weixiaoduo.com/topic/23258/#post-23269" title=" 回覆至:重定向 bbPress 個人資料連結到自定義連結地址,如主題自帶的使用者中心。">7 年、 4 月前</a>