I am trying to stop the BuddyPress Inivitation custom post from being created if the user is an admin as they don't want to record their invitations and only see there others.
I found in /plugins/invite-anyone/by-email/by-email-db.php a line that seems to let me do this
// Let plugins stop this process if they want
do_action( 'invite_anyone_before_invitation_create', $r, $args );'
However, I created a function to try it and it does not seem to stop the function
add_action('invite_anyone_before_invitation_create', 'test_check_invite_create', 10, 2);
function test_check_invite_create($r, $args) {
$user = get_user_by( 'email', $r['invitee_email'] );
//print_r($user);
if (current_user_can('manage_options')) {
//do not create post
exit('do not create!'); //stops page
$r['invitee_email'] = '';
return false; //return $r ???
} else {
//create post as normal
//return true;
}
}
This may be a more general WP question, but how do I use an action to stop the function and return false? I've done it with filters but that doesn't seem to work here.