Skip to content

Commit

Permalink
Introduce flag for adding noindex tag to inactive profile pages.
Browse files Browse the repository at this point in the history
See #3400.
  • Loading branch information
boonebgorges committed Jun 26, 2024
1 parent 2b10b5c commit c206862
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions wp-content/themes/openlab/lib/member-funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2201,3 +2201,34 @@ function openlab_portfolio_link_visibility_ajax_cb() {
wp_send_json_success();
}
add_action( 'wp_ajax_openlab_portfolio_link_visibility', 'openlab_portfolio_link_visibility_ajax_cb' );

/**
* Determines whether a user's profile should have the noindex meta tag.
*
* @param int $user_id User ID.
* @return bool
*/
function openlab_should_noindex_user_profile( $user_id ) {
$noindex = get_user_meta( $user_id, 'openlab_noindex_user_profile', true );

return (bool) $noindex;
}

/**
* Adds the noindex meta tag to a user's profile.
*/
function openlab_add_noindex_to_user_profile() {
if ( ! bp_is_user() ) {
return;
}

$user_id = bp_displayed_user_id();
if ( ! $user_id ) {
return;
}

if ( openlab_should_noindex_user_profile( $user_id ) ) {
echo '<meta name="robots" content="noindex" />' . "\n";
}
}
add_action( 'wp_head', 'openlab_add_noindex_to_user_profile', 0 );

0 comments on commit c206862

Please sign in to comment.