Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Last active August 29, 2015 14:07
Show Gist options
  • Save bentasm1/f45163b84ab4bbbf7eba to your computer and use it in GitHub Desktop.
Save bentasm1/f45163b84ab4bbbf7eba to your computer and use it in GitHub Desktop.
/* Adds Stories & Blogs links to profile pages */
function authorposts_onprofile() {
global $bp;
?>
<li id="activity-reshares"><a href="<?php echo home_url(). '/author/' . bp_get_displayed_user_username(). '/'; ?>" title="<?php bp_displayed_user_fullname(); ?>'s Stories and Blogs">Stories & Blogs</a></li>
<?php
}
add_action('bp_member_options_nav', 'authorposts_onprofile');
---- Second attempt -- still no good. Hrm -----------
/* Checks post count for users on profile page to send to story & blog links */
function wpb_user_has_posts($user_id) {
$result = new WP_Query(array(
'author'=>$user_id,
'post_type'=>'post',
'post_status'=>'publish',
'posts_per_page'=>1,
));
return (count($result->posts)!=0);
}
/* Adds Stories & Blogs links to profile pages */
function authorposts_onprofile() {
global $bp;
$user = wp_get_current_user();
if ($user->ID)
if (wpb_user_has_posts($user->ID))
echo '<li id="activity-reshares"><a href="' . home_url(). '/author/' . bp_get_displayed_user_username() . '/">Stories & Blogs</a></li>';
else
echo '';
}
add_action('bp_member_options_nav', 'authorposts_onprofile');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment