wernerB
In den letzten 30 Tagen erstellte Support-Threads: 0
Lieblings-Forenthemen
This user has no favorite topics.
Forum Topics Created
Status | Thema | Supporter | Stimmen | Artikel | Aktualität |
---|---|---|---|---|---|
Toolset and Appmysite
Gestartet von: wernerB in: Toolset Professional Support |
2 | 4 | vor 3 Jahren | ||
push notification
Gestartet von: wernerB
in: Toolset Professional Support
Problem: Solution: |
2 | 3 | vor 6 Jahren, 1 Monat | ||
Beitragsreferenz
Gestartet von: wernerB in: Toolset Professioneller Support |
2 | 5 | vor 6 Jahren, 1 Monat | ||
Only show current User’s posts in post reference field
Gestartet von: 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 | vor 6 Jahren, 2 Monaten | ||
Post Form with relation
Gestartet von: wernerB in: Toolset Professional Support |
3 | 8 | vor 6 Jahren, 2 Monaten |