简体   繁体   English

将用户配置文件字段添加到Wordpress Buddypress以包括“收藏夹”

[英]Adding User Profile Fields to Wordpress Buddypress to Include “Favorites”

I'm trying to figure out a way for members on my Wordpress (Buddypress) site to pick their "favorite movies, books, etc." 我正在尝试寻找一种方法让Wordpress(Buddypress)网站上的成员选择“喜欢的电影,书籍等”。

It would be nice if, instead of members simply typing a list of these things, they could select from books already in the system, and add more as the please in the future. 如果他们可以从系统中已有的书中进行选择,并在将来添加更多内容,而不是简单地输入这些列表,这将是很好的选择。

I'm hoping that there is an easy answer to this, such as a plugin that I can use, or, at least, modify. 我希望对此有一个简单的答案,例如可以使用或至少可以修改的插件。 Does anyone know of anything that I can look into? 有谁知道我可以研究的内容?

Your title asks how to add a user profile field. 您的标题询问如何添加用户个人资料字段。 Here is the code to add as many fields as you like. 这是添加任意多个字段的代码。 Once you add the field, you can easily place additional inputs or options on the custom tab page for users to enter their own favorites. 添加字段后,您可以轻松地在自定义选项卡页面上放置其他输入或选项,以使用户输入自己的收藏夹。

function my_test_setup_nav() {
global $bp; 
$parent_slug = ‘test’;
$child_slug = ‘test_sub’;
//name, slug, screen, position, default subnav
bp_core_new_nav_item( array(‘name’ => __( ‘Test’ ),’slug’ => $parent_slug,’screen_function’ => ‘my_profile_page_function_to_show_screen’,'position’ => 40,’default_subnav_slug’ => $child_slug ) );
/* Add the subnav items to the profile */
// name, slug, parent_url, parent slug, screen function
bp_core_new_subnav_item( array( ‘name’ => __( ‘Home’ ), ‘slug’ => $child_slug, ‘parent_url’ => $bp->loggedin_user->domain . $parent_slug.’/', ‘parent_slug’ => $parent_slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen’ ) );
bp_core_new_subnav_item( array( ‘name’ => __( ‘Random Page’ ), ‘slug’ => ‘random’, ‘parent_url’ => $bp->loggedin_user->domain . $parent_slug.’/', ‘parent_slug’ => $parent_slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen234′ ) );
}

function my_profile_page_function_to_show_screen() {

//add title and content here – last is to call the members plugin.php template
add_action( ‘bp_template_title’, ‘my_profile_page_function_to_show_screen_title’ );
add_action( ‘bp_template_content’, ‘my_profile_page_function_to_show_screen_content’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}

function my_profile_page_function_to_show_screen_title() {
echo ‘wptaskforce title’;
}

function my_profile_page_function_to_show_screen_content() {
echo ‘wptaskforce content’;
}


//random page content: 
function my_profile_page_function_to_show_screen234() {
//add content here – last is to call the members plugin.php template
add_action( ‘bp_template_content’, ‘my_profile_page_function_to_show_screen234_content’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}
function my_profile_page_function_to_show_screen234_content() {
echo ‘This is a random page.’;

} 
add_action( ‘bp_setup_nav’, ‘my_test_setup_nav’ );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM