Skip Navigation

[Resolved] Mathcing post field called with current user

This thread is resolved. Here is a description of the problem and solution.

Problem:

The wpcf-users will have multipe email addresses - I am trying to create a loop where if current user's email mathces any one of the email addresses the post title will appear - however at the moement it only appears if the current users email matches the 1st instance of wpcf-use and not the nth instance.

Solution:

Please try [wpv-for-each] shortcode, for example:

https://toolset.com/forums/topic/mathcing-post-field-called-with-current-user/#post-1205953

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by adamG-6 5 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1205918

The wpcf-users will have multipe email addresses - I am trying to create a loop where if current user's email mathces any one of the email addresses the post title will appear - however at the moement it only appears if the current users email matches the 1st instance of wpcf-use and not the nth instance.

Here is my code so far

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->

<wpv-loop>
[wpv-conditional if="( $(wpcf-users) eq '[wpv-current-user info='email']' )"]

  • [wpv-post-title]
  • [/wpv-conditional]
    </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-layout-end]

    #1205953

    Hello,

    I assume we are talking about a custom multiple-instance email field "users", created with Types plugin.

    Please try [wpv-for-each] shortcode, for example, replace these codes from:

    [wpv-conditional if="( $(wpcf-users) eq '[wpv-current-user info='email']' )"]
    <a href="[wpv-post-url]">[wpv-post-title]</a>
    [/wpv-conditional]
    

    To:

    [wpv-for-each field="wpcf-users"]
    [types field="users" output="raw"][/types]
    [wpv-conditional if="( '[types field="users" output="raw"][/types]' eq '[wpv-current-user info='email']' )"]<a href="[wpv-post-url]">[wpv-post-title]</a>[/wpv-conditional]
    [/wpv-for-each]
    

    More help:
    https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each

    #1208975

    My issue is resolved now. Thank you!