重定向 Buddypress 的编辑个人资料页面

Redirect the edit profile page of Buddypress

我的客户在他的 Wordpress 网站上使用 Buddypress,但他不希望用户在 Buddypress 中编辑他们的个人资料。

他也不希望用户在单击 管理栏 时转到他们的 /profile/edit 页面。

所以我正在寻找一种方法将管理栏中的 url 更改为配置文件视图页面,或者将 profile/edit 页面重定向到配置文件视图页面的方法。

因此来自:http://[website-url]/members/[username]/profile/edit/

收件人:http://[website-url]/members/[username]/

对如何实现这一点有什么想法吗?

我用下面的代码解决了这个问题:

<?php $classes = get_body_class();

   if (in_array('profile-edit',$classes)) {     
       wp_redirect( bp_loggedin_user_domain() ); exit;
    };

?>

这段代码调用正文的class。如果正文 class 中有 'profile-edit' 则调用 wp_redirect 函数。此函数请求 BuddyPress 登录用户个人资料页面的 url 并将他发送到该页面。