Skip to content

Instantly share code, notes, and snippets.

@g-maclean
Created March 26, 2025 11:03
Show Gist options
  • Save g-maclean/52622dcba5408212f511209223dcc859 to your computer and use it in GitHub Desktop.
Save g-maclean/52622dcba5408212f511209223dcc859 to your computer and use it in GitHub Desktop.
PropertyHive - Force login to use shortlist feature
add_filter( 'propertyhive_single_property_actions', 'force_user_login_for_shortlist', 999 );
function force_user_login_for_shortlist( $actions )
{
//if user is logged in skip
if ( is_user_logged_in() )
{
return $actions;
}
// get shortlist action
foreach ( $actions as $action )
{
if ( $action['class'] == 'action-shortlist' )
{
$action['href'] = wp_login_url( get_permalink() );
$action['attributes'] = array( 'rel' => 'nofollow' );
$new_actions[] = $action;
}
else
{
$new_actions[] = $action;
}
}
return $new_actions;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment