Php Wordpress-创建自定义帖子并允许用户仅编辑此帖子
我有个案子 我有一个自定义帖子类型,定义为:Php Wordpress-创建自定义帖子并允许用户仅编辑此帖子,php,wordpress,Php,Wordpress,我有个案子 我有一个自定义帖子类型,定义为: add_action('init', 'my_custom_galerie_absolwentow'); function my_custom_galerie_absolwentow() { $labels = array( 'name' => _x('Galerie absolwentów', 'post type general name'), 'singular_name' => _x('Galeria abs
add_action('init', 'my_custom_galerie_absolwentow');
function my_custom_galerie_absolwentow()
{
$labels = array(
'name' => _x('Galerie absolwentów', 'post type general name'),
'singular_name' => _x('Galeria absolwentów', 'post type singular name'),
'add_new' => _x('Dodaj nową galerię', 'Blog'),
'add_new_item' => __('Dodaj nową'),
'edit_item' => __('Edycja'),
'new_item' => __('Nowa'),
'view_item' => __('Zobacz'),
'search_items' => __('Szukaj'),
'not_found' => __('Nie znaleziono żadnych galerii'),
'not_found_in_trash' => __('Nie znaleziono żadnych galerii w koszu'),
'parent_item_colon' => '',
'has_archive' => 'galerie-absolwentow'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array(
'slug' => 'galerie-absolwentow',
'with_front' => false
),
'capability_type' => 'post',
'hierarchical' => true,
'menu_position' => 15,
'supports' => array('title','editor','thumbnail','page-attributes'),
'has_archive' => 'galerie-absolwentow'
);
register_post_type('galerie-absolwentow',$args);
}
当创建具有指定角色的用户时,我正在创建状态为“草稿”的新帖子
add_action ('user_register', "add_post_to_absolwent_user");
function add_post_to_absolwent_user($user_id)
{
if ($_POST['role']=='absolwent'):
$absolwent_page = array(
'post_title' => __($_POST['first_name'].' '.$_POST['last_name']),
'post_content' => 'Tutaj należy wprowadzić krótki opis strony Absolwenta.',
'post_type' => 'galerie-absolwentow',
'comment_status' => 'closed',
'post_status' => 'draft'
);
$absolwent_page_id = wp_insert_post($absolwent_page);
endif;
}
此代码正常,并执行我想执行的操作:)
我需要做什么才能让创建的用户访问创建的帖子。
这就是全部。
其他一切都不应该是可访问的
这可能吗?
如何实现这一点有什么提示吗