Linking user to file upload?
Hi there, I asked earlier about making a public form for allowing authenticated users add files to a specific pod. I was successful in making this form. I was also successful in making the list of all the files with their associated fields. My problem now is, how do I attribute the user who created the pod entry to the actual entry? I looked at this thread : http://podscms.org/qna/questions/1506/showing-pods-entries-to-admin-and-only-the-author-user, which shined a bit of light, but I don't really get the whole:
> Install the package Auto Set Current > User, then set this as the input > helper for your pick column. That will > automatically set the user who is > entering the data. My column name is > called "author". I have it set only on > the public form, so if I edit the item > from the admin page, I don't end up > owning the submission.
I installed the Auto Set Current User helper. I made a column named author and set the column type to relationship (pick) > related to WP User and have tried using input helper auto_set_current_user and not. Either way, if I don't use the input helper, and manually chose the user in an 'add new' window, the user isn't contained in the array if I
$listItem = new Pod('testfilepod');
print_r($listItem);
I think I may be missing something conceptually? I'm new to pods, so if someone could rudimentarily steer me in the right direction, I would be very thankful.
Much appreciated!
Tre
1 Answer
You don't ever get all the user data pulled into pods. What you get is a pointer to the record in the wp_users database. You can't directly access this table without using a wp user object.
Here is some code from one of my sites that shows a logged in user only their posts:
<?php
global $current_user, $user_ID , $user_level;
get_currentuserinfo(); //Get the information about the current user.
if ($user_ID): //Check to see if the user is logged in
$pods = new Pod('my_pod');
$pods->findRecords('id DESC', 50, "author.ID = $user_ID");
$gravatar_url = "http://www.gravatar.com/avatar/" . md5( strtolower( trim ($current_user->user_email) ) );
?>
<div style='float:right;'>
<a href='http://www.gravatar.com' target='_blank' title='Visit Gravatar.com to edit your image'><img src='<?php echo $gravatar_url;?>' alt='' /></a>
</div>
<h2> Hello <?php echo $current_user->display_name;?></h2>
<p><small><b>Actions:</b>
<?php if (current_user_can('edit_others_posts')) echo "<a href='" . get_bloginfo('url') . "/wp-admin'>Admin Page»</a> "; ?>
<?php if (current_user_can('edit_posts')) echo "<a href='" . get_bloginfo('url') . "/wp-admin/edit.php'>Edit Your Posts»</a> "; ?>
<a href='<?php bloginfo('url'); ?>/wp-admin/profile.php'>Edit your profile»</a>
<h3>Your submissions:</h3><hr />
<table>
<tr style="font-weight:bold;"><th></th><th></th><th>Status</th><th>Name</th><th>Last Modified</th></tr>
<?php echo $pods->showTemplate('user_submissions');?>
</table>
<?php
if (current_user_can('publish_posts')): //is admin
$pods->findRecords('id DESC', 50, "t.submitted = true AND t.publish = false");?>
<br /><br />
<h3>Submissions Awaiting Review</h3>
<hr />
<table>
<tr style="font-weight:bold;"><th></th><th></th><th>Status</th><th>Name</th><th>Last Modified</th></tr>
<?php echo $pods->showTemplate('user_submissions');?>
</table>
<?php endif; //is admin
else:
?>
<h2>Please Login</h2>
<p>You must <a href="<?php echo wp_login_url(); ?>">Log In</a> or <?php wp_register(' ', ' '); ?> to see this page.</p>
<?php
endif;


