Home Forums General Issues how to display the author's name Reply To: how to display the author's name

  • Hi @flexi2202,

    Is your form only visible to logged in users? I assume you’re logged in as non-admin?

    I think you need to use the acf_form() parameters

    On of the parameters is: html_after_fields.

    As you’re logged in, you can access the user ID:
    $user_id = get_current_user_id();

    So you could then use a hidden value:
    'html_after_fields' => '<input type="hidden" name="acf[author_id]" value="'.$user_id.'"/>',

    Using acf/save_post

    You can then grab the hidden value and updated the post author:

    add_action('acf/save_post', 'my_acf_save_post');
    function my_acf_save_post( $post_id ) {
    	$arg = array(
    		'ID' => $post_id,
    		'post_author' => $_POST['acf']['author_id']
    	wp_update_post( $arg );	

    Code is untested but should point you in the right direction