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.

Regards,
Nidhi

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

<apex:page id="portalUserProfilePage" controller="CustomMyProfilePageController" showHeader="false" title="{!$Label.site.my_profile_page}">
  <!-- <apex:composition template="{!$Site.Template}"> -->
  <html>
  <body>
    <!-- <apex:define name="body"> -->
        <apex:form id="theForm">
          <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetail" rendered="{!isEdit}">
           <!-- <apex:pageBlock title="{!$Label.site.my_profile}" id="editUserDetail" rendered="{!isEdit}"> -->
             <apex:pageMessages />
             <!-- <apex:pageBlockButtons id="editButtons" location="top"> -->
               <apex:commandButton id="save" value="{!$Label.site.save}" action="{!save}" rerender="userDetail"/>
               <apex:commandButton id="cancel" value="{!$Label.site.cancel}" action="{!cancel}" rerender="userDetail" immediate="true"/>
             <!-- </apex:pageBlockButtons> -->
             <apex:pageBlockSection id="editUserSection" columns="1" title="{!$Label.site.user_information}">
                 <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>
             <apex:pageBlockSection id="editContactSection" columns="2" title="{!$Label.site.contact_information}">
                 <apex:inputField id="editfirstName" value="{!user.firstName}"/>
                 <apex:inputField id="editemail" value="{!user.email}"/>
                 <apex:inputField id="editlastName" value="{!user.lastName}"/>
                 <apex:inputField id="editphone" value="{!user.phone}"/>
                 <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>
               <apex:pageBlockSection id="editAddressInformation" columns="1" title="{!$Label.site.address_information}">
                 <apex:inputField id="editstreet" value="{!user.street}"/>
                 <apex:inputField id="editcity" value="{!user.city}"/>
                 <apex:inputField id="editstate" value="{!user.state}"/>
                 <apex:inputField id="editpostalcode" value="{!user.postalcode}"/>
                 <apex:inputField id="editcountry" value="{!user.country}"/>
               </apex:pageBlockSection>
           <!-- </apex:pageBlock>     -->  
             </apex:outputPanel>
           
             <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetails" rendered="{!!isEdit}">
            <!-- <apex:pageBlock title="{!$Label.site.my_profile}" id="viewUserDetail" rendered="{!!isEdit}"> -->
                 <!-- <apex:pageBlockButtons id="detailButtons" location="top"> -->
                   <apex:commandButton id="edit" value="{!$Label.site.edit}" action="{!edit}" rerender="userDetail"/>
                   <apex:commandButton id="changePassword" value="{!$Label.site.change_password}" action="{!changePassword}"/>
                 <!-- </apex:pageBlockButtons> -->
                 <!-- <apex:pageBlockSection id="viewUserSection" columns="2" title="{!$Label.site.user_information}"> -->
                     <!-- <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="{!$Label.site.contact_information}"> -->
                     <b>Email : </b> <apex:outputField id="detailemail" value="{!user.email}"/> <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="{!user.phone}"/>
                     <apex:outputField id="detailstreet" value="{!user.street}"/>
                     <apex:outputField id="detailcity" value="{!user.city}"/>
                     <apex:outputField id="detailstate" value="{!user.state}"/>
                     <apex:outputField id="detailpostalcode" value="{!user.postalcode}"/>
                     <apex:outputField id="detailcountry" value="{!user.country}"/>
                     <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:outputPanel>
         </apex:form>
    <!-- </apex:define> -->
    </body>
    </html>
<!-- </apex:composition> -->
</apex:page>



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, contact.email
                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() {
        isEdit=true;
    }

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

        try {
            update user;
            if (user.contact != null) {
                update user.contact;
            }
            isEdit=false;
        } catch(DmlException e) {
            ApexPages.addMessages(e);
        }
    }

    public PageReference changePassword() {
        return Page.ChangePassword;
    }

    public void cancel() {
        isEdit=false;
        user = [SELECT id, email, username, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax, contact.email
                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.email = u.email;
        c.phone = u.phone;
        c.mobilephone = u.mobilephone;
        c.fax = u.fax;
        c.mailingstreet = u.street;
        c.mailingcity = u.city;
        c.mailingstate = u.state;
        c.mailingpostalcode = u.postalcode;
        c.mailingcountry = u.country;
    }
}
sandeep@Salesforcesandeep@Salesforce
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.