Passing variable from template file to the plugin file
You can use this way: private function display_images( $args ) { $instagram_url = get_user_meta($user_data->ID, ‘instagram_url’, true); $username = $instagram_url; //You can use $username in another function by simply call it using global method. } This is an easy way to get the post meta data in your custom plugin file.