Last active
July 4, 2017 00:30
-
-
Save toddlahman/8974365 to your computer and use it in GitHub Desktop.
API Manager api_manager_extra_software_activation_data filter hook function usage example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function api_manager_example_get_sku( $post_id, $data ) { | |
global $wpdb; | |
$sku = $wpdb->get_var( $wpdb->prepare( " | |
SELECT meta_value FROM {$wpdb->prefix}postmeta | |
WHERE post_id = %s | |
AND meta_key = '_sku' | |
LIMIT 1 | |
", $post_id ) ); | |
return $sku; | |
/** | |
* Other Examples of how to return data. | |
*/ | |
/* | |
$new_data = array ( 'sku1' => 'test1', 'sku2' => 'test2' ); | |
return array_merge( $data, $new_data ); | |
// or | |
$data['sku1'] = 'test1'; | |
$data['sku2'] = 'test2'; | |
return $data; | |
*/ | |
} | |
add_filter( 'api_manager_extra_software_activation_data', 'api_manager_example_get_sku', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment