Support: Add fields to forms editor - aMember Pro v.4

Discussion in 'aMember Pro v.4' started by lee_pro, Apr 1, 2013.

  1. lee_pro

    lee_pro New Member

    Joined:
    Mar 26, 2013
    Messages:
    26
    I'm using aMember Pro v.4 to management users of website use CMS Wordpress.

    - On aMember allow add field to form sign up when guest register a account.
    - aMember allow sync user with wordpress when user add new account on aMember.
    - When I add new a field to form sign up. aMember process to save to database.
    - To amember could save this new data field on wordpress. I need to configure anything?

    Ex: I add field 'birthday' on form sign up. when user register, this field save to database of aMember.
    I need config anything to field 'birthday' save to database wordpress with account new create.

    Please help me!

    Thanks you!
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    This is possible with customization.
    What is the type of your birthday field in amember? (common or SQL)
    What is the name of your birthday field in wordpress?
    lee_pro likes this.
  3. lee_pro

    lee_pro New Member

    Joined:
    Mar 26, 2013
    Messages:
    26
    In aMember, I add fields: birthday, gender.
    In wordpress. user meta : birthday, gender.
    I want affter sign up success. fiels: birthday, gender save to wordpress (i config the same video support : link ). See image Sign up form:


    Thanks!

    Attached Files:

  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Edit /amember/application/default/plugins/protect/wordpress/wordpress.php find this function:
    PHP:
            function updateMetaTags(Am_Record $recordUser $user)
            {
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'first_name'$user->name_f);
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'last_name'$user->name_l);
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'nickname'$user->login);
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'rich_editing''true');
            }

    change it to:
    PHP:
            function updateMetaTags(Am_Record $recordUser $user)
            {
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'first_name'$user->name_f);
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'last_name'$user->name_l);
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'nickname'$user->login);
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'rich_editing''true');
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'birthday'$user->birthday);
                
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'gender'$user->gender);
            }

  5. lee_pro

    lee_pro New Member

    Joined:
    Mar 26, 2013
    Messages:
    26
    Hi, I edit /amember/application/default/plugins/protect/wordpress/wordpress.php find this function:
    Code:
    function updateMetaTags(Am_Record $record, User $user)
            {
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'first_name', $user->name_f);
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'last_name', $user->name_l);
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'nickname', $user->login);
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'rich_editing', 'true');
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'birthday', $user->birthday);
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'gender', $user->gender);
            }
    But, not update field : birthday, gender to wordpress.
    * I debug:
    Code:
    function updateMetaTags(Am_Record $record, User $user)
            {
                echo '<pre>';
                    var_dump('birthday: ',$user->birthday);
                    var_dump('gender: ',$user->gender);
                    var_dump($user);
                echo '</pre>';
                die;
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'first_name', $user->name_f);
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'last_name', $user->name_l);
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'nickname', $user->login);
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'rich_editing', 'true');
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'birthday', $user->birthday);
                $this->_plugin->getWP()->update_user_meta($record->pk(), 'gender', $user->gender);
            }
    var_dump('birthday: ',$user->birthday); //$user->birthday : null
    var_dump('gender: ',$user->gender); //$user->gender : null
    View image:

    Attached Files:

  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Ok. Use this in order to get these fields values:
    PHP:
    $user->data()->get("birthday");
    $user->data()->get("gender");

  7. smiddleton67

    smiddleton67 New Member

    Joined:
    Mar 28, 2013
    Messages:
    9
    Regarding the birthday field, if we use the code below, the birthday is displayed correctly in aMember but incorrect in WordPress

    PHP:
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'birthday'$user->data()->get("birthday"));
    We updated the code for the birthday field like below :

    PHP:
    $this->_plugin->getWP()->update_user_meta($record->pk(), 'birthday'strtotime($user->data()->get("birthday")));
    Then it can be sync from aMember to WordPress, however it is displayed not the same between aMember and WordPress.

    For example: if the birthday is 02/15/1988 (February 15, 1988 ). It is 02/15/1988 in aMember but it is 02/14/1988 in WordPress.

    Please advice!
  8. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    I guess there is something about timezone in WP. Try this:

    PHP:
    $this->_plugin->getWP()->update_user_meta(
        
    $record->pk(), 'birthday',
        
    12*3600 strtotime($user->data()->get('birthday')) // add 12 hours
    );
  9. smiddleton67

    smiddleton67 New Member

    Joined:
    Mar 28, 2013
    Messages:
    9
    Thanks, support!
    If i have the user_id. I want to get the infomation of birthday, gender.
    Please advice!
  10. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Use this code:
    PHP:
    $user Am_Di::getInstance()->userTable->load($user_id); 
    $user->data()->get('birthday');

Share This Page