I'm trying to modify a function in a plugin so that it only returns the custom post type (venues) of the user that’s logged in (by default it displays all venues). This is my first time customizing a function, so any help would be greatly appreciated!
This is what I've put into my functions.php file:
global $current_user;
get_currentuserinfo();
if ($post->post_author == $current_user->ID) {
add_action('tribe_events_community_form', 'community_events_venue_select_menu_current_user');
function community_events_venue_select_menu_current_user( $event_id = null ) {
if ( !$event_id ) {
global $post;
if( isset( $post->post_type ) && $post->post_type == 'tribe_events' ) {
$event_id = $post->ID;
} elseif( isset( $post->post_type ) && $post->post_type == 'tribe_venue' ) {
return;
}
}
do_action( 'tribe_venue_table_top', $event_id );
}
}
I'm getting the following two errors for the function, even though there are thousands of the 'tribe_events' and 'tribe_venue' post types in my database:
Notice: Undefined variable: post
Notice: Trying to get property of non-object
on this line:
if ($post->post_author == $current_user->ID) {
Additionally, when I changed the name of the default function (in the plugin) to my custom function name, its returning this error:
Fatal error: Call to undefined function community_events_venue_select_menu_current_user()
TribeEvents::POSTTYPE
(thinking that might throw an error since it was code from within the plugin) totribe_events
, which is the exact value of the post_type in my posts table, but that still returns the same two errors.$post
too late. Define it when you set$current_user