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

CRM-21212 Include getUfId function for wordpress to help getting E2E … #11017

Merged
merged 1 commit into from
Oct 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CRM/Utils/System/WordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,20 @@ public function permissionDenied() {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}

/**
* Determine the native ID of the CMS user.
*
* @param string $username
* @return int|NULL
*/
public function getUfId($username) {
$userdata = get_user_by('login', $username);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 is there a reason you want to use get_user_by() as opposed to get_current_user_id() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kcristiano I saw its what is used in the function just above in L334, The purpose of this i think is that in the E2E tests we are passing through a user name + pw and authenticating then wanting to get the id back

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct - I was not thinking about the proper context. As we are running tests we need to pas in the user name = pw.

if (!$userdata->data->ID) {
return NULL;
}
return $userdata->data->ID;
}

/**
* @inheritDoc
*/
Expand Down