glowlogix / wp-frontend-profile

WP Frontend Profile allows users to edit/view their profile and register/login without going into the dashboard to do so.
https://wordpress.org/plugins/wp-front-end-profile/
GNU General Public License v2.0
17 stars 20 forks source link

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

Closed danloughmiller closed 1 year ago

danloughmiller commented 2 years ago

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);
afifa-glowlogix commented 1 year ago

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

hasnain37 commented 1 year ago

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

hasnain37 commented 1 year ago

@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);