Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Ultimate Member and Ajax Search Pro › Reply To: Ultimate Member and Ajax Search Pro
July 13, 2020 at 1:48 pm
#28417
Participant
Hi Ernest, here is the answer I got from ultimate members support.
Re: New Support Request: programmatical way to check if the user has access
Hi,
Thanks for getting in touch. You can use following function to check if current logged in user has access to certain page/post, change $post_id to actual ID and you can replace “get_current_user_id()” with any user ID to check this.
function has_access() {
$access = true;
$restriction = get_post_meta( $post_id, 'um_content_restriction', true ); //This array contains all content restriction settings
if ( isset($restriction['_um_access_roles']) ) { //this gives the array of restricted roles
$access = UM()->Access()->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
}
return $access;
}
Do you think you can work your magic with this information? I’d really appreciate it as this filtered search that displays results according to the user role is the heart of the website we are building…