Update user profile link handling in frontend

Refactored methods to change user profile edit and comment author URL logic, ensuring compatibility with Ultimate Member plugin's structure. Updated readme file to reflect changes and fixed bugs related to profile link display in the comments section.
This commit is contained in:
Mykyta Synelnikov
2025-09-05 12:08:19 +03:00
parent 2b8d964a1d
commit 58fdd9f943
2 changed files with 30 additions and 5 deletions
+23 -4
View File
@@ -1,6 +1,8 @@
<?php
namespace um\frontend;
use WP_Comment;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@@ -19,8 +21,8 @@ if ( ! class_exists( 'um\frontend\User_Profile' ) ) {
*/
public function __construct() {
add_action( 'template_redirect', array( $this, 'handle_edit_screen' ), 10000 );
add_filter( 'get_edit_user_link', array( $this, 'get_um_edit_user_link' ), 10, 2 );
add_filter('get_comment_author_url', array( $this, 'get_comment_author_url' ), 10, 3);
add_filter( 'get_edit_user_link', array( $this, 'change_edit_user_link' ), 10, 2 );
add_filter( 'get_comment_author_url', array( $this, 'change_comment_author_url' ), 10, 3 );
}
/**
@@ -70,11 +72,28 @@ if ( ! class_exists( 'um\frontend\User_Profile' ) ) {
}
}
public function get_um_edit_user_link( $link, $user_id ) {
/**
* Returns the user profile edit link using Ultimate Member plugin.
*
* @param string $link The default edit user link.
* @param int $user_id The ID of the user.
*
* @return string The customized user profile edit link.
*/
public function change_edit_user_link( $link, $user_id ) {
return um_edit_profile_url( $user_id );
}
public function get_comment_author_url( $comment_author_url, $comment_id, $comment ) {
/**
* Retrieves the user profile URL for the given comment author.
*
* @param string $comment_author_url The URL of the comment author.
* @param int $comment_id The ID of the comment.
* @param WP_Comment $comment The comment object.
*
* @return string The user profile URL for the comment author.
*/
public function change_comment_author_url( $comment_author_url, $comment_id, $comment ) {
return um_user_profile_url( $comment->user_id );
}
}
+7 -1
View File
@@ -167,9 +167,15 @@ No specific extensions are needed. But we highly recommended keep active these P
IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSION 2.6.7 PATCHES SECURITY PRIVILEGE ESCALATION VULNERABILITY. PLEASE SEE [THIS ARTICLE](https://docs.ultimatemember.com/article/1866-security-incident-update-and-recommended-actions) FOR MORE INFORMATION
= 2.10.6 2025-07-xx =
= 2.10.6 2025-09-xx =
**Enhancements**
* Added: Avoid caching of the UM Forms on the mobile devices via adding the nocache headers to the screens with UM Forms.
**Bugfixes**
* Fixed: Changed the view and the edit user profile links in the comments section on the frontend.
= 2.10.5 2025-06-25 =