When using the LearnDash profile block (or shortcode), there is an “Edit Profile” link that appears beneath the user’s avatar. By default, this link takes the user to the backend of WordPress, to the WordPress profile page.
You can change where that link sends them and use a custom URL instead.
The following PHP snippet can be used to override the link and send the user to a custom URL of your choice. Replace https://www.learndash.com/
with the link to your own profile page.
add_filter( 'get_edit_user_link', function( $original_url ) {
/**
* Not a LearnDash-specific snippet
* Could apply to any link output by calling this WordPress core function
*
* @link https://developer.wordpress.org/reference/functions/get_edit_user_link/
*/
// Check to see if user can edit_users, if not, return a different Edit Profile link
if ( ! current_user_can( 'edit_users' ) ) {
// Replace the below URL with your custom front-end "Edit Profile" page
return 'https://www.learndash.com';
}
// If the current user has the edit_users capability (like an admin), let them easily access admin-side tools
return $original_url;
} );
NOTE
If you’re using the Design Upgrade Pro for LearnDash plugin, this option is already available in the Customizer. You should use that option, as adding this code could interfere with code in the plugin.