Browse: Home / Snippets /

Override ‘Edit profile’ link in ld_profile shortcode

Contents


Snippet #

Important: All snippets are provided as-is without support or guarantees. These snippets are provided as guidelines for advanced users looking to customize LearnDash. For any additional help or support with these snippets, we recommend reaching out to a LearnDash Expert.

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.example.com';
	}
	
	// If the current user has the edit_users capability (like an admin), let them easily access admin-side tools
	return $original_url;
} );