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!
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?
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!
Edit /amember/application/default/plugins/protect/wordpress/wordpress.php find this function: PHP: 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'); } change it to: PHP: 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); }
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:
Ok. Use this in order to get these fields values: PHP: $user->data()->get("birthday");$user->data()->get("gender");
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!
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);
Thanks, support! If i have the user_id. I want to get the infomation of birthday, gender. Please advice!
Use this code: PHP: $user = Am_Di::getInstance()->userTable->load($user_id); $user->data()->get('birthday');