Skip to content

Commit

Permalink
UM: hide name, email, and images in the form by default
Browse files Browse the repository at this point in the history
  • Loading branch information
pryley committed Oct 19, 2024
1 parent e6dc78c commit 794066d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/integrations/ultimatemember.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
],
'settings.integrations.ultimatemember.form' => [
'class' => 'large-text',
'default' => '[site_reviews_form assigned_users="profile_id"]',
'default' => '[site_reviews_form assigned_users="profile_id" hide="name,email,images"]',
'depends_on' => [
'settings.integrations.ultimatemember.enabled' => ['yes'],
'settings.integrations.ultimatemember.display_reviews_tab' => ['yes'],
],
'label' => _x('Form Shortcode', 'admin-text', 'site-reviews'),
'placeholder' => '[site_reviews_form assigned_users="profile_id"]',
'placeholder' => '[site_reviews_form assigned_users="profile_id" hide="name,email,images"]',
'sanitizer' => 'text',
'tooltip' => _x('Enter the form shortcode used on the profile page', 'admin-text', 'site-reviews'),
'type' => 'text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public function filterProfileTabs(array $tabs): array
return $tabs;
}

/**
* @filter site-reviews/review/value/author
*/
public function filterReviewAuthorValue(string $value, TagContract $tag): string
{
if ($user = $tag->review->user()) { // @phpstan-ignore-line
$url = um_user_profile_url($user->ID);
return sprintf('<a href="%s">%s</a>', $url, $value);
}
return $value;
}

/**
* @filter site-reviews/reviews/fallback
*/
Expand All @@ -47,7 +59,7 @@ public function filterReviewsFallback(string $fallback, array $args): string
*/
public function filterSummaryPercentagesValue(string $value, TagContract $tag): string
{
if (!empty(array_sum($tag->ratings))) {
if (!empty(array_sum($tag->ratings))) { // @phpstan-ignore-line
return $value;
}
return '';
Expand All @@ -69,7 +81,7 @@ public function filterSummaryRatingValue(string $value, TagContract $tag): strin
*/
public function filterSummaryTextValue(string $value, TagContract $tag): string
{
if (!empty(array_sum($tag->ratings))) {
if (!empty(array_sum($tag->ratings))) { // @phpstan-ignore-line
return $value;
}
if (get_current_user_id() === um_get_requested_user()) {
Expand Down Expand Up @@ -117,8 +129,10 @@ protected function shortcodeForm(): string

protected function shortcodeReviews(): string
{
add_filter('site-reviews/review/value/author', [$this, 'filterReviewAuthorValue'], 20, 2);
add_filter('site-reviews/reviews/fallback', [$this, 'filterReviewsFallback'], 20, 2);
$shortcode = do_shortcode(glsr_get_option('integrations.ultimatemember.reviews'));
remove_filter('site-reviews/review/value/author', [$this, 'filterReviewAuthorValue'], 20);
remove_filter('site-reviews/reviews/fallback', [$this, 'filterReviewsFallback'], 20);
return $shortcode;
}
Expand Down

0 comments on commit 794066d

Please sign in to comment.