Last active
August 29, 2015 14:07
-
-
Save bentasm1/f45163b84ab4bbbf7eba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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