This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko 8 years, 11 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › How to search only in posts where the author is the user?
This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko 8 years, 11 months ago.
I want to display the results post_author for the logged in user.
Hi again!
If I understand correctly, then you only want to show results, that were created by the current logged in users?
This is only possible by modifying the search source or creating a filtering function. Try to add this code anywhere to your theme functions.php file:
add_filter( 'asp_pagepost_results', 'asp_filter_the_post_author', 1, 1 ); function asp_filter_the_post_author( $pageposts ) { foreach ($pageposts as $k=>$v) { global $current_user; get_currentuserinfo(); $user = get_user_by( 'id', $current_user->ID ); // Get the user nicename $author = $user->data->user_nicename; // Remove the post from the array if the author is not the logged in user if ($pageposts[$k]->author != $author) unset($pageposts[$k]); } return $pageposts; }
You must be logged in to reply to this topic.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |