wp-frontend-profile icon indicating copy to clipboard operation
wp-frontend-profile copied to clipboard

When WPFEP_Profile::get_profile_url() is invoked the filter is not applied if not page is selected

Open danloughmiller opened this issue 2 years ago • 2 comments

When WPFEP_Profile's get_profile_url() is called there's an 'early out' if no page is selected which bypasses the filter applied later in the function. My goal was to send the user to the author's post's page.

        public function get_profile_url()
        {
            $page_id = wpfep_get_option('profile_page', 'wpfep_pages', false);

            if (! $page_id) {
                return false;
            }

            $url = get_permalink($page_id);

            return apply_filters('wpfep_profile_url', $url, $page_id);
        }

Without a dummy page selected this filter cannot be applied:

add_filter('wpfep_profile_url', function($url, $page_id) {
    if (!empty(get_current_user_id()))
        return get_author_posts_url( get_current_user_id() );

    return $url;
}, 10, 2);

danloughmiller avatar Aug 25 '22 14:08 danloughmiller

@hasnain37 did you look into it? What's the status?

afifa-glowlogix avatar Nov 08 '22 07:11 afifa-glowlogix

@afifa-glowlogix yes I have checked that issue and will resolve by this week.

hasnain37 avatar Nov 08 '22 09:11 hasnain37

@danloughmiller issue has been fixed , you can now use filter as following

add_filter('wpfep_profile_url', function($url) { if (!empty(get_current_user_id())) return get_author_posts_url( get_current_user_id() ); return $url; }, 10, 2);

hasnain37 avatar Jan 05 '23 15:01 hasnain37