Are your User and Profile models not associated/related to each other - User hasOne/belongsTo Profile? If you have that relationship, then just query for the Profile with user_id equal the Auth->user('id') :) Enjoy, John
On Mar 22, 2:39 am, "Dave" <make.cake.b...@gmail.com> wrote: > This might be odd but i have user email and profile email. > User email is not published on the site (used for account, login, forgot > stuff like that) profile email is published on the site so for security i > figured that its best to use a separate email. > > So when a user wants to edit either of the emails i need to make sure they > are not the same so both cant be myn...@somewhere.com. > > How would i validate 1 field based on 2 different models using Auth->id > since the email is directly related to the logged in user? > > I figured query the opposite table to see if this users email is the same as > this profile email (or vice versa depending onwhichis being changed) but how > do i use the auth id in this? > > validation rule: > array( > 'rule' => array('notSameAsUser', 'email'), > 'message' => 'Your public email address can not be the same as your > account email.', > 'last' => true) > > function: > > function notSameAsUser( $data ) { > > $valid = false; > > $params = array( > 'conditions' => array('Profile.id' => $id),//how do i get the id from > Auth in the model? > 'fields' => array('User.email') > 'contain' => array( > 'User' => array( > 'fields' => array( > 'User.email')))); > > $data $this->find('first', $params); > > if ( $data['User']['email'] != $data['Profile']['email'] ) { > $valid = true; > > } > > return $valid; > > } > > Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.