Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fix for global posts leading to "directorist_author_profile" shortcut-page #1168

Open
wants to merge 1 commit into
base: alpha
Choose a base branch
from

Conversation

AbyssWaIker
Copy link
Contributor

In our theme (typer) url to author profile is taken not from login but from "user_nicename".

So everything I needed to do is to add is get_user_by( 'slug', $user_id) in addition to existing get_user_by( 'login', $user_id).

But if "get user_by()" doesn't find matching user (with \WP_User::get_data_by( $field, $user_id )) it just returns current user (making "get_current_user_id()" in the function redundant).

So I made a small refactor to make code cleaner and add slug check

In our theme (typer) url to author profile is taken not from login but from "user_nicename".

So everything I needed to do is to add is get_user_by( 'slug', $user_id) in addition to existing get_user_by( 'login', $user_id).

But if "get user_by()" doesn't find matching user (with \WP_User::get_data_by( $field, $user_id )) it just returns current user (making "get_current_user_id()" in the function redundant).

So I made a small refactor to make code cleaner and add slug check
@AbyssWaIker AbyssWaIker changed the title Fix for when "directorist_author_profile" is used for global posts Small fix for global posts leading to "directorist_author_profile" shortcut-page Sep 6, 2022
@AbyssWaIker
Copy link
Contributor Author

Turned out my entire use-case was based on the fact that "regenerate page" has overriden "front user profile" page...
It's not really needed anymore.

Still, this little commit makes code a bit more readable, maintanable and prepared for links in wp's "user_nicename" format (specifically made to be url-friendly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant