wernerB
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Toolset and Appmysite
Started by: wernerB in: Toolset Professional Support |
2 | 4 | 2 years, 12 months ago | ||
push notification
Started by: wernerB
in: Toolset Professional Support
Problem: Solution: |
2 | 3 | 6 years ago | ||
Beitragsreferenz
Started by: wernerB in: Toolset Professioneller Support |
2 | 5 | 6 years, 1 month ago | ||
Only show current User’s posts in post reference field
Started by: wernerB
in: Toolset Professional Support
Problem: I have a post reference field that shows all the posts. I would like to filter the options so that only posts by the current logged-in User are shown. Solution: Use this custom code snippet: /* --------------------------------------------- */ // FILTER POST REFERENCE FIELD // Filter the posts in a post reference field by author, where the author is the current User function filter_reference_posts( $query ){ $target_page = 12345; // ID of page with form, or string of page slug $ref_post_type = "cpt-slug"; // slug of post type in the post reference field if ( ( is_page( $target_page ) || ( defined('DOING_AJAX') && DOING_AJAX ) ) && is_array($query->get( 'post_type')) && in_array($ref_post_type, $query->get('post_type')) ) { $current_user = get_current_user_id(); $query->set( 'author', $current_user ); } } add_action( 'pre_get_posts', 'filter_reference_posts' ); |
2 | 3 | 6 years, 1 month ago | ||
Post Form with relation
Started by: wernerB in: Toolset Professional Support |
3 | 8 | 6 years, 1 month ago |