Skip to content

Instantly share code, notes, and snippets.

@andreiglingeanu
Created February 14, 2024 09:48
Show Gist options
  • Save andreiglingeanu/0692b691a424f324fc302ed7a9c2650b to your computer and use it in GitHub Desktop.
Save andreiglingeanu/0692b691a424f324fc302ed7a9c2650b to your computer and use it in GitHub Desktop.
<?php
add_filter(
'blocksy:pro:content-blocks:condition-match',
function ($matches, $content_block_id) {
if ($content_block_id === 15054) {
$resume_id = get_queried_object_id();
if (! resume_manager_user_can_view_resume($resume_id)) {
return false;
}
}
return $matches;
},
10,
2
);
@indigetal
Copy link

This is fantastic! The specific Content Block filter used is re-implementing the "View Resume Capability" setting of the WP Job Manager Resumes addon to a Content Block that is overriding the content-single-resume.php template file of that plugin. However, I can see how any content block filter can be added inside the callback function passed to the add_filter function. So this is also very useful across many other similar situations where we will want to add a filter to any Content Block for any reason!

I put this code in a content-blocks-controls.php file in the child theme and removed the content-single-resume.php template override from it. The view resume capability for the Content Block is again controlled by the WPJM Resume's setting.

Chef's Kiss Guys!

@andreiglingeanu
Copy link
Author

@indigetal I'm glad to hear we found a solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment