如何仅通过“添加”和“修改”选项在用户自己的广告网页内容上授予用户权限?我正在使用PHP,Apache,MySql和wordpress。 请给我代码示例。
我正在使用以下代码:
<?php
$object = new Pod('dreams');
$object->ui = array('title' => 'My Pod' ,'add_fields' => array('name' ,'position','photo','bio','eom'),'edit_fields' => array('name' ,'position','photo','bio','eom','approved'));
//load Pod
$pod = new Pod('dreams');
if(current_user_can('administrator')) {
//set publicForm() visible fields for admins
$object->ui = array('title' => 'My Dream' ,'add_fields' => array('name' ,'position','photo','bio','eom'),'edit_fields' => array('name' ,'position','photo','bio','eom','approved'));
pods_ui_manage($object);
} else if(is_user_logged_in()) {
// Get the last URL variable
$slug = pods_url_variable('1');
$Edit = new Pod('team', $slug);
$name = $Edit->get_field('name');
$author_id = $Edit->get_field('author_id'); // GET AUTHOR FROM POD
$user_id = $current_user->ID;
global $current_user; // GET USER INFO
get_currentuserinfo();
$object->ui = array('title' => 'My Dream' ,'add_fields' => array('name' ,'position','photo','bio','eom'),'edit_fields' => array('name' ,'position','photo','bio','eom','approved'));
pods_ui_manage($object);
// $edit_listing = (($author_id == $current_user->ID) || (current_user_can('manage_options') == true) ? true : false); //
}; ?> <br/><br/>
<table>
<div><h1>Create a Dream</h1>
<p>What is this Dream, what do I want to do, accomplish, achieve?</p>
<p>Does this Dream involve someone else?</p>
<p>What tools are available to help achieve this Dream?</p>
<p>What steps can I take to help me achieve this Dream?</p>
<?php $pod->publicForm($fields); ?>
</div></table>
现在,用户还可以查看和编辑所有其他用户帖子。但事实并非如此。
答案 0 :(得分:0)
在“ui”数组中,您需要添加额外的“where”和“edit_where”子句。
'where' => 'p.author_id = ' . $user_id,
'edit_where' => array('author_id' => $user_id)