Use a single email address in users table and add a display_email
field in Profile to allow the users to specify whether it will be
displayed publicly. Having 2 email fields will only confuse people.

On Mar 22, 2:21 pm, "Dave" <[email protected]> wrote:
> User hasOne Profile belongsTo User
> But I think im just going to put 2 email fields in the user table and just
> do it that way rather than 1  in user and 1 in profile.
>
> Thanks for your suggestions guys.
>
> dave
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf
>
> Of John Andersen
> Sent: March-22-10 4:33 AM
> To: CakePHP
> Subject: Re: Weird Validation Question
>
> 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" <[email protected]> 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 [email protected].
>
> > 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 sitehttp://cakeqs.organd 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 [email protected] To
> unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> cake-php+athttp://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.
>
>

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 [email protected]
To unsubscribe from this group, send email to
[email protected] 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.

Reply via email to