Skip to content
Advertisement

PHP logic “and” “&&” for WordPress site restriction

I have two different user roles on my Website: Employer and Candidate. Every one had a type of profile but the profile from Candidate should see only employers and nobody else.

So I want a restriction in WordPress like:

Employer CAN see Candidate Candidate CAN’T see other Candidate Candidate CAN see own Profile

This is controlled by a plugin but it seems to be broken BECAUSE:

Employer CAN see Candidate Candidate CAN see other Candidate Candidate CAN’T see own Profile

In the .php file from candidate profile is this code:

JavaScript

and the code for results right after code from above:

JavaScript

The check 3 is the only one check showing profile.

I tried to change the “&&” “||” “==” but i can’t figure it out how this logic work.

So much php is too much for me. I have asked the Plugin creator but I am always waiting 5 days to reply and I need it now.

I would be very happy if someone would help me with this.

Thank you very much!

Martin

Advertisement

Answer

This code should work according to the behavior you have described(of course it will depend on the good functionality of your plugin). I had to take off some conditions since I don’t know what they are and also you didn’t provide further details, if you need them you have to add later, but this is quite simple and this code is much more readable.

First portion:

JavaScript

Second portion:

JavaScript

If you want more tests, like about profile being public or not, you really have to provide more information. I hope it can help you.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement