Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following code within my visualforce page, this ensures only users with the Portal profile can see the page, otherwise they are shown the SFDC page.

<apex:page standardController="News__c" action="{!if($Profile.Name =='Portal', null,
        urlFor($Action.News__c.View, News__c.Id, null, true))}" tabstyle="News__tab">

How can I edit this code so that it can have multiple conditions? i.e. Portal AND Standard profiles can view the current page.

share|improve this question
up vote 2 down vote accepted

Since you are only using the StandardController, you can just do something like this...

action="{!if($Profile.Name == 'Portal' || $Profile.Name == 'Standard', ...>

As a suggestion though, this type of logic is much better suited for a custom controller. Sticking a lot of conditional logic in your VF markup is kind of an anti-pattern IMO.

share|improve this answer

K, the following answer is one way to add multiple conditions via an Apex Controller. Its not the only way to do it.

Google "Visualforce functions" to see how to add an OR() function to your VF logic.

Below is an example of achieving the same conditions using Apex

The action parameter of apex:page invokes a method from a controller. You'd can to write a controller extension similar to the following:

VF Page:

<apex:page standardController="News__c" extensions="NewsExtension" action="{!profileCheck}">


public class NewsExtension {
    // constructor
    public NewsExtension(ApexPages.StandardController sCon){ }

    public PageReference profileCheck(){
        String userProfileName = [SELECT Name FROM Profile WHERE Id = :UserInfo.getProfileId()].Name;
        if(userProfileName == 'Portal' || userProfileName == 'Standard')
            return null; // no - redirect
        return new PageReference('/theRedirectPage');
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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