0

I would like to hide some portion in view post base on author.

My requirement is that I have an job board theme and user can post the job. So there is "How to Apply" section in detail page.

Now, I want to auto post from other job site feed by using a author called "Aggregator". He has a role called "Aggregator".

So I want to hide "How To Apply" section, if post author role is "Aggregator".

May I know How to get and check post author role?

Thanks, Alex

1 Answer 1

0
if( !in_array('Aggregator', get_the_author_meta('roles')) ){
    //If user is not aggrigator display the info
}

That will get the authors roles as an array for the current post. You can pass a post id along with the 'roles' to get the data from another post.

Also note that your Aggrigator role is possibly set-up in word press in lower-case so make the if statement reflect this.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.