【问题标题】:check if field has new value in buddypress xprofile检查buddypress xprofile中的字段是否有新值
【发布时间】:2012-06-04 15:58:10
【问题描述】:

当用户使用新值更新其个人资料字段“国家/地区”或“城市”时,我希望仅收到具有新值的字段的通知。目前我正在使用它,但不知道哪些字段已被修改:

add_action ('xprofile_updated_profile', 'profile_change_notify');
function profile_change_notify ($vars = array ())
{
    $user = new WP_User ($vars['user_id']);
    wp_mail ('myname@mydomain.com', 'Subject ( ' . $user->user_login . ' just updated the Profile )', 'Message Body goes here.');
}

感谢您的帮助..

【问题讨论】:

    标签: wordpress field buddypress


    【解决方案1】:

    请使用以下代码:

    function update_xprofile_country_state($user_id) {
        if (!empty($user_id)) {
                $user = new WP_User ($user_id);
            if (!empty($_POST['country'])) {
                     wp_mail ('myname@mydomain.com', 'Subject ( ' . $user->user_login . ' just updated the Profile )', 'Message Body goes here.');
            }
        }
    }
    add_action('xprofile_updated_profile', 'update_xprofile_country_state', 0, 1);
    

    这里你从 $_POST 变量中得到了值。 如果从用户配置文件更新了 contry 值,则发送邮件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      相关资源
      最近更新 更多