Home Forums Front-end Issues Yoast Schema Person ID and ACF issue Reply To: Yoast Schema Person ID and ACF issue

  • I cannot find any documentation on the hook wpseo_schema_person or what is passed to your filter.

    Searching the code I can also not find where this hook is called specifically. I can only find 2 places where filtering is done that may be where this is happening.

    // the first one
    $graph_piece = \apply_filters( 'wpseo_schema_' . $identifier, $graph_piece, $context );
    // the second one
    $graph_piece = \apply_filters( 'wpseo_schema_' . $type, $graph_piece, $context );

    Your issue is that in order to get the values from the ACF fields for a user you need to supply the correct $post_id

    $altAuthorName = get_field('alt_author_name', 'user_'.$user_id);

    If the user ID is not supplied in one of the arguments when the filter is applied there is likely no possibility of you being able to alter this. What you need to do is to output all of what is being supplied and see if the user ID is in there.

    You may need to adjust the priority up or down in this.

    add_filter( 'wpseo_schema_person', 'example_change_person', 10, 2 );
    function example_change_person( $data, $context ) {
      echo '<pre>'; var_dump($data); echo '</pre>';
      echo '<pre'>; var_dump($context); echo '</pre>';