function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nidhi MalhotraNidhi Malhotra 

Custom My Profile Page

Hi All the experts out there! I need your help with the following code.

I am trying to replicate the custom My Profile Visual force page. I am using the standard Visual force page and controller that was available in the instance.

I modified it and commented certain lines. After commenting certain lines I found that the Command buttons are not functioning properly.
The reason I commented some pageblock section tags and all is that I want this page to be custom. I will add other header and logos using HTML. I also want only certain fields to be editable. That is the reason I have commented certain lines.

But after doing so, the command buttons itself does not function. Or when I try to click it, I am not even able to click it.

Can anyone please help me to fix this? All that I want is that this page to be functional with few fields but no standard salesforce styling inside that. If everything is in wile background also that is also great. I even want to retain the change password function. Also the change password page should not have standard salesforce syling.

Please help me to fix this issue.


Apex Page ~~~~~~~~~~~~~~~~~~~~~~~

<apex:page id="portalUserProfilePage" controller="CustomMyProfilePageController" showHeader="false" title="{!$}">
  <!-- <apex:composition template="{!$Site.Template}"> -->
    <!-- <apex:define name="body"> -->
        <apex:form id="theForm">
          <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetail" rendered="{!isEdit}">
           <!-- <apex:pageBlock title="{!$}" id="editUserDetail" rendered="{!isEdit}"> -->
             <apex:pageMessages />
             <!-- <apex:pageBlockButtons id="editButtons" location="top"> -->
               <apex:commandButton id="save" value="{!$}" action="{!save}" rerender="userDetail"/>
               <apex:commandButton id="cancel" value="{!$}" action="{!cancel}" rerender="userDetail" immediate="true"/>
             <!-- </apex:pageBlockButtons> -->
             <apex:pageBlockSection id="editUserSection" columns="1" title="{!$}">
                 <apex:inputField id="editusername" value="{!user.username}"/>
                 <apex:inputField id="edittimezone" value="{!user.timezonesidkey}"/>
                 <apex:inputField id="editlocale" value="{!user.localesidkey}"/>
                 <apex:inputField id="editlanguage" value="{!user.languagelocalekey}"/>
                 <apex:inputField id="editcommunityNickname" value="{!user.communityNickname}"/>
             <apex:pageBlockSection id="editContactSection" columns="2" title="{!$}">
                 <apex:inputField id="editfirstName" value="{!user.firstName}"/>
                 <apex:inputField id="editemail" value="{!}"/>
                 <apex:inputField id="editlastName" value="{!user.lastName}"/>
                 <apex:inputField id="editphone" value="{!}"/>
                 <apex:inputField id="edittitle" value="{!user.title}"/>
                 <apex:inputField id="editextension" value="{!user.extension}"/>
                 <apex:pageBlockSectionItem />
                 <apex:inputField id="editfax" value="{!user.fax}"/>
                 <apex:pageBlockSectionItem />
                 <apex:inputField id="editmobile" value="{!user.mobilephone}"/>
               <apex:pageBlockSection id="editAddressInformation" columns="1" title="{!$}">
                 <apex:inputField id="editstreet" value="{!user.street}"/>
                 <apex:inputField id="editcity" value="{!}"/>
                 <apex:inputField id="editstate" value="{!user.state}"/>
                 <apex:inputField id="editpostalcode" value="{!user.postalcode}"/>
                 <apex:inputField id="editcountry" value="{!}"/>
           <!-- </apex:pageBlock>     -->  
             <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetails" rendered="{!!isEdit}">
            <!-- <apex:pageBlock title="{!$}" id="viewUserDetail" rendered="{!!isEdit}"> -->
                 <!-- <apex:pageBlockButtons id="detailButtons" location="top"> -->
                   <apex:commandButton id="edit" value="{!$}" action="{!edit}" rerender="userDetail"/>
                   <apex:commandButton id="changePassword" value="{!$}" action="{!changePassword}"/>
                 <!-- </apex:pageBlockButtons> -->
                 <!-- <apex:pageBlockSection id="viewUserSection" columns="2" title="{!$}"> -->
                     <!-- <apex:outputField id="detailusername" value="{!user.username}"/>
                     <apex:outputField id="detailtimezone" value="{!user.timezonesidkey}"/>
                     <apex:outputField id="detaillocale" value="{!user.localesidkey}"/>
                     <apex:outputField id="detaillanguage" value="{!user.languagelocalekey}"/>
                     <apex:outputField id="detailcommunityNickname" value="{!user.communityNickname}"/> -->
                 <!-- </apex:pageBlockSection> -->
                 <!-- <apex:pageBlockSection id="viewContactSection" columns="2" title="{!$}"> -->
                     <b>Email : </b> <apex:outputField id="detailemail" value="{!}"/> <br/>
                     <b>Name : </b><apex:outputField id="detailfirstName" value="{!user.firstName}"/> <br/>
                     <!-- <b></b><apex:outputField id="detaillastName" value="{!user.lastName}"/> -->
                     <b>Title : </b><apex:outputField id="detailtitle" value="{!user.title}"/> <br/>
                     <!-- <apex:outputField id="detailphone" value="{!}"/>
                     <apex:outputField id="detailstreet" value="{!user.street}"/>
                     <apex:outputField id="detailcity" value="{!}"/>
                     <apex:outputField id="detailstate" value="{!user.state}"/>
                     <apex:outputField id="detailpostalcode" value="{!user.postalcode}"/>
                     <apex:outputField id="detailcountry" value="{!}"/>
                     <apex:outputField id="detailextension" value="{!user.extension}"/>
                     <apex:outputField id="detailfax" value="{!user.fax}"/>
                     <apex:outputField id="detailmobile" value="{!user.mobilephone}"/> -->
                 <!--</apex:pageBlockSection> -->
               <!-- </apex:pageBlock> -->
    <!-- </apex:define> -->
<!-- </apex:composition> -->

Controller ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
* An apex class that keeps updates of a portal user in sync with its corresponding contact.
   Guest users are never able to access this page.
public with sharing class CustomMyProfilePageController {

    private User user;
    private boolean isEdit = false;

    public User getUser() {
        return user;

    public CustomMyProfilePageController() {
        user = [SELECT id, email, username, usertype, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax,
                FROM User
                WHERE id = :UserInfo.getUserId()];
        // guest users should never be able to access this page
        if (user.usertype == 'GUEST') {
            throw new NoAccessException();

    public Boolean getIsEdit() {
        return isEdit;

    public void edit() {

    public void save() {
        if ( != null) {
            setContactFields(, user);

        try {
            update user;
            if ( != null) {
        } catch(DmlException e) {

    public PageReference changePassword() {
        return Page.ChangePassword;

    public void cancel() {
        user = [SELECT id, email, username, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax,
                FROM User
                WHERE id = :UserInfo.getUserId()];

    public static void setContactFields(Contact c, User u) {
        c.title = u.title;
        c.firstname = u.firstname;
        c.lastname = u.lastname; =; =;
        c.mobilephone = u.mobilephone;
        c.fax = u.fax;
        c.mailingstreet = u.street;
        c.mailingcity =;
        c.mailingstate = u.state;
        c.mailingpostalcode = u.postalcode;
        c.mailingcountry =;
Can you please open debug in monitor and then click on command button it will definitely be useful way to find error as in your post you have not mention any error message (from back hand) so please try to debug it, we can debug otherwise.