• First of all, thanks to you Chester for sharing to us your amazing work!

    I have a question regarding virtual fields.
    In the Admin of the plugin you wrote: “Airpress Virtual Fields allow you to automatically retrieve Airtable records for each post/page/etc by specifying a WordPress field (such as ID or post_name) and an Airtable table and field.” so I suppose I can use wordpress fields (other than post_title or id) to match with Airtable column.

    I’m trying to retrieve Airtable records by specifying the user_email field from wp_signups table (https://codex.wordpress.org/Database_Description#Table:_wp_signups) but I got the following error message (https://www.dropbox.com/s/ap8wyp8it9cv25n/Screenshot%202018-12-13%2022.39.20.png?dl=0)

    I’d like to know if I do something wrong or how to achieve this with Airpress.
    Many thanks in advance!
    Roni

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chester McLaughlin

    (@chetmac)

    You can accomplish this by not using VirtualFields and instead adding something like this to your functions.php (or a plugin):

    add_action( 'the_post', 'add_some_airtable_data' );
    
    function add_some_airtable_data( $post ){
    
    	// you can target a specific custom post type
    	if ( get_post_type() == "post" ){ 
    
    		// you can target a specific post slug/name
    		if ( $post->post_name == "hello-world"){ 
    
    			// you can target a specific category
    			if ( has_category("uncategorized") ){ 
    
    				// Setup AirpressQuery with Table Name and Config ID/Name
    				$query = new AirpressQuery("Furniture", 0);
    
    				// You can statically provide a filter
    				$query->addFilter(sprintf("{Name} = '%s'", "Byam Rug"));
    
    				// Or you can get a custom meta value from the post
    				//$values = get_post_custom_values( 'My Custom Field' );
    				//$query->addFilter(sprintf("{Name} = '%s'", $values[0]));
    				
    				// the property 'AirpressCollection' is what all Airpress shortcodes
    				$post->AirpressCollection = new AirpressCollection($query);
    
    			}
    
    		}
    
    	}
    
    }
    Thread Starter ronzi26

    (@ronzi26)

    Thanks a lot for your response Chester!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Retrieving Airtable records by specifying user’s email’ is closed to new replies.