Support

Account

Home Forums Front-end Issues Get_field with user_id and post_id

Solved

Get_field with user_id and post_id

  • Hi,

    I am currently using ACF: Star Rating Field.

    My code are as follow:

    <?php 
    	//based on POST
    	if ( function_exists( 'the_field' ) ) {
    
            $star_rating = get_field( 'field_55b60d9089739', get_the_ID());
            
            print_r($star_rating);
        }
    
        ?>

    How do I get the get_the_ID() to work with get_current_user_id()?

    I tried

    $args = array{
    'user_id' => get_current_user_id(), 
    	'post_id' => get_the_ID()
    }

    but can’t seem to get it to work.

    Also if possible, may I know how do I use the update_field to work with ACF: Star Rating Field? I am trying to allow the user to change their vote when they have submitted.

  • I’m not exactly sure what you trying to do. Are you trying to get a field from a user page? Please explain more about what you mean by:

    How do I get the get_the_ID() to work with get_current_user_id()?

  • My intention is to combine both post_id and user_id hoping to get field that is very specific to it and use update_field to change the content.

    After experimenting a while I realised that is not possible to combine both (maybe I am wrong).

    Anyway I decided to use wpdb to delete the field and update the content.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Get_field with user_id and post_id’ is closed to new replies.