Skip to content

Instantly share code, notes, and snippets.

@hamidrezayazdani
Created September 4, 2022 19:35
Show Gist options
  • Save hamidrezayazdani/c0c302846816624090ca6bbf9bca2630 to your computer and use it in GitHub Desktop.
Save hamidrezayazdani/c0c302846816624090ca6bbf9bca2630 to your computer and use it in GitHub Desktop.
Redirect Comment to Ultimate member Login page on "You must be logged in to post a comment".
<?php
/**
* Change Default Comment Login link to UM Login Page
*/
if ( ! function_exists( 'ywp_um_change_login_link' ) ) {
function ywp_um_change_login_link( $defaults ) {
if ( class_exists( 'UM' ) ) {
$defaults['must_log_in'] = '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), um_get_core_page( 'login' ) ) . '</p>';
return $defaults;
}
}
}
add_filter( 'comment_form_defaults', 'ywp_um_change_login_link' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment