Since we will rely on a code snippet, there is little what's not possible.
It is possible to send the User ID in a Form notification using %%USER_USERID%%, to both users submitting the form or to an email (such as the Admin) or else, as visible when you create a User Form. We also have it available in the Forms API.
Whichever way you choose to let the Admin know which user requested, or should have access, the Admin will have to save this data.
The problem is we cannot use select fields as those cannot be repeating, and you need to add more than one user.
Using Repeatable Field Groups is a bit overkill for this, given we would need to query a lot of related posts to find the allowed authors.
So I suggest, a simple single-line field that holds the user IDs or emails if you prefer.
How you inform the Admin about which user needs to be added to what post, is another topic that (if you need help with), I suggest discussion in another thread.
Assuming the Admin knows what to add to which post, let's say the Admin will add Emails, he will have to add the emails of each user that has co-author access to a post to this single line field, like so:
email1@email.com,email2@email.com,email3@email.com
Then, you can craft a Custom Code that get_post_meta() this value (gets the value of the single-line field with PHP and WordPress API Code)
That value should then be exploded and put in an array (one key each email).
Then we can check if the current users' email is within that array it in_array() PHP function.
We can then return either true or false in our code, hook this to the WordPress shortcode API and use it in a HTML condition, where we will display a link to the edit form of the post, only if our code returns true (which means, our logged in user's email is within the emails stored for the post as co-author)
That code looks like follows, please consider the comments and adapt to your site:
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
//<em><u>hidden link</u></em>
$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
//<em><u>hidden link</u></em>
if (in_array($current_user_email, $field_values_array)) {
return true;
}
else {
return false;
}
}
add_shortcode( 'user-can-author', 'user_can_author' );
It relies on a single line field with slug user-can-do, where the admin adds the emails of the users in a comma-separated fashion as above explained.
Then we use it in an HTML condition like so:
[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]
This should not require a lot of adaptation on your site, but the code should be reviewed and comprehended, please let me know if you have any doubts left on its function and maintenance.