-
-
Save mikejolley/9668782 to your computer and use it in GitHub Desktop.
// Hook into user_has_cap filter. This assumes you have setup resumes to require the capability 'has_active_job_package' | |
add_filter( 'user_has_cap', 'has_active_job_package_capability_check', 10, 3 ); | |
/** | |
* has_active_job_package_capability_check() | |
* | |
* Filter on the current_user_can() function. | |
* | |
* @param array $allcaps All the capabilities of the user | |
* @param array $cap [0] Required capability | |
* @param array $args [0] Requested capability | |
* [1] User ID | |
* [2] Associated object ID | |
*/ | |
function has_active_job_package_capability_check( $allcaps, $cap, $args ) { | |
// Only interested in has_active_job_package | |
if ( empty( $cap[0] ) || $cap[0] !== 'has_active_job_package' || ! function_exists( 'wc_paid_listings_get_user_packages' ) ) { | |
return $allcaps; | |
} | |
$user_id = $args[1]; | |
$packages = wc_paid_listings_get_user_packages( $user_id, 'job_listing' ); | |
// Has active package | |
if ( is_array( $packages ) && sizeof( $packages ) > 0 ) { | |
$allcaps[ $cap[0] ] = true; | |
} | |
return $allcaps; | |
} |
Hi everybody,
As @jmurphy444, it's not working for me...
I added "has_active_job_package" in settings and added the code snippet, first in the plugin, now in my functions.php file... it doesn't work.
Any idea ?
I have created 3 packages Free, Pro, Business. I want to give a certain page access to the only those users who have an active business package. How can i do that?
Make sure and follow the documentation guys, you have to add this under capabilities in the resume configuration as well:
https://wpjobmanager.com/document/tutorial-require-an-active-job-package-to-view-resumes/
Do you have a list of hooks? I'm trying to build something similar that adds a job package for free when a user purchases a subscription (was trying to use one of the woocommerce product bundles plugins to do this but they don't work with the custom product types provided by wpjm).
This is not working for me......all EMPLOYERS can see all resumes......any ideas?