[-] Check if current logged in user is within the users stored in a Custom Field on a Post

This is useful when you, for example, want to add more than an author to a post (using Toolset forms, it is not a backend ready solution)

For it to work you need a field that stores User (emails, in this case), with slug user-can-do

That field needs to be populated in any post with a commaseparated list of user emails like so

email1@email.com,email2@email.com,email3@email.com

Then, you can use the below shortcode in an HTML condition, to check if the current logged in user is within those users stored for the user-can-do field of the post.

function user_can_author( $atts ){
 
    //We get the current logged in user email, see https://developer.wordpress.org/reference/functions/wp_get_current_user/
    $current_user_email = wp_get_current_user()->user_email;
 
    //we get the value of the single line field saved against the post, with all those emails of users that an co-author
    //https://developer.wordpress.org/reference/functions/get_post_meta/
    //We get the ID of the post with get_the_ID(), see https://developer.wordpress.org/reference/functions/get_the_id/
    $field_value = get_post_meta(get_the_ID(),'wpcf-user-can-do', true);
 
    //We explode tha commaseparated string to an array where the email will be value of each key
    //https://www.php.net/manual/function.explode.php
    $field_values_array = explode( ',', $field_value );
 
    //Use below to debug the code
    //error_log(print_r($field_value, true));
    // error_log(print_r($field_value, true));
    // error_log(print_r($field_values_array, true));
  
    //Here we check if the current user email is within the emails stored for $field_value
    //https://www.php.net/manual/de/function.in-array.php
    if (in_array($current_user_email, $field_values_array)) {
        return true;
    }
    else {
        return false;
    }
  
}
add_shortcode( 'user-can-author', 'user_can_author' );

use this like so in an HTML condition after registering the shortcode in Toolset > Settings:

[wpv-conditional if="( '[user-can-author]' eq '1' )"]
   The current user has access to this post, display a form or link to a form
[/wpv-conditional]

Note, there is also a version of this where the field is stored in a user, and it saves Post Ids the user has access to, as seen here
https://toolset.com/forums/topic/grant-revoke-access-to-image-visibility-based-on-user/page/2/#post-1489243