Support

Account

Home Forums ACF PRO Steve Jobs and Bill Gates – Relationship issue Reply To: Steve Jobs and Bill Gates – Relationship issue

  • Hi @james,
    thank you for oyur reply and helping me out.

    I can some coding but I am not good at WP :/

    I have added this code to the functions.php file:

    function my_relationship_query( $args, $field, $post_id ) {
    	
        // only show children of the current post being edited
        $args['post_parent'] = $post_id;
    	
    	
    	// return
        return $args;
        
    }
    
    // filter for a specific field based on it's name
    add_filter('acf/fields/relationship/query/name=report_relations', 'my_relationship_query', 10, 3);
    
    

    Now I want the report_relations field to only show the following:

    I have a post meta named “p2p_user_to_client_to”, the post_id in the postmeta table refers to the userID and the meta_value refers to a custom post type named “client”.

    So basically I just want the the following in human language:

    Get all the rows in the table for (Logged in user == postmeta.post_id)
    AND
    Get the custom post types WHERE post_type == client and post_type_id == (is whatever meta_value is for the found rows in the postmeta table).

    I dont know really know how to imeplemtn this to the function above since I dont know how WP works.

    If you can help me out I would be very very glad.

    Thanks a lot for your help @James!

    regards