2 回答

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超8個(gè)贊
所以它可能就像這樣簡(jiǎn)單:
//very close to your initial code
add_filter( 'um_profile_tabs', 'um_videos_tab', 1000 );
function um_videos_tab( $tabs ) {
$tabs['videos'] = array(
'name' => 'Videos',
'icon' => 'um-icon-ios-videocam',
'custom' => true
) ;
return $tabs ;
}
//profile tab content
//based on how it appears UM has set up its action hooks
add_action( 'um_profile_content_videos', 'um_profile_content_videos' ) ;
function um_profile_content_videos() {
//got to watch the apostrophes vs quotes so things don't get mixed up
echo do_shortcode( ' [aiovg_user_videos id="' . um_profile_id() . '"] ' ) ;
}
我的不確定性部分基于這樣一個(gè)事實(shí),即我既沒(méi)有 UM 也沒(méi)有生成 aiovg_user_videos 短代碼的任何東西,因此無(wú)法測(cè)試或調(diào)試??紤]到我有點(diǎn)盲目,在詳細(xì)研究 UM 代碼之前,我的下一次嘗試是_default在語(yǔ)句中添加“標(biāo)記”和“處理程序” add_action——add_action( 'um_profile_content_videos_default', 'um_profile_content_videos_default' ) ;以防萬(wàn)一這是對(duì)這些掛鉤的要求。

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超9個(gè)贊
我終于弄明白了!??!這就是最終起作用的!
/**
* Add a new Profile tab
* @param array $tabs
* @return array
*/
function um_videos_add_tab( $tabs ) {
$tabs[ 'videos' ] = array(
'name' => 'Videos',
'icon' => 'um-icon-ios-videocam',
'custom' => true
);
UM()->options()->options[ 'profile_tab_' . 'videos' ] = true;
return $tabs;
}
add_filter( 'um_profile_tabs', 'um_videos_add_tab', 1000 );
/**
* Render tab content
* @param array $args
*/
function um_profile_content_videos_default( $args ) {
/* START. You can paste your content here, it's just an example. */
$action = 'videos';
$member_user_id = um_get_requested_user();
echo do_shortcode( "[aiovg_user_videos id=" . $member_user_id . "]" );
/* END. You can paste your content here, it's just an example. */
}
add_action( 'um_profile_content_videos_default', 'um_profile_content_videos_default' );
- 2 回答
- 0 關(guān)注
- 128 瀏覽
添加回答
舉報(bào)