while working on vitamovie.com theme they needed a download link for registered only users, the solution
the custom field they used is videoembed, but you can use whatever you want, this is very useful if you have something in a custom field that you want registered users to see only
`
<?php
if (is_user_logged_in()){
echo '<a href= "' . get_post_meta($post->ID, 'videoembed', true) . '">Download</a>';
}
else {
echo '<a href="http://www.site.com/wp-register.php">
Download - Please Register and Log In</a>';
};
?>
`
Where do I exactlt place this code?
Thanking you.
anywhere you want really, preferably if your theme has a single.php, which is the file used to display one post. you can place in there, its just a link that is active only when the user is logged in, if the user is not logged in it goes to the registration page, the cool thing is that the link source is taken from the custom field area called videoembed in this case, you can change that to whatever custom field you are using,
for example in the wordpress default theme you can place it after the
< ?php } edit_post_link('Edit this entry','','.'); ?>link in the single.php page,or after the
< ?php the_tags( 'Tags: ', ', ', ''); ?>
i recommend putting a div around the link, or some styling tag