Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Last active January 16, 2026 16:40
Show Gist options
  • Select an option

  • Save yuriinalivaiko/66ed25518b2919211809747c4a18038a to your computer and use it in GitHub Desktop.

Select an option

Save yuriinalivaiko/66ed25518b2919211809747c4a18038a to your computer and use it in GitHub Desktop.
Code snippets for the "Verified Users" extension
<?php
// Apply the role's auto-verify feature when the role is changed manually.
if ( function_exists( 'um_after_user_role_is_updated' ) ) {
add_action( 'add_user_role', 'um_after_user_role_is_updated', 20, 2 );
add_action( 'set_user_role', 'um_after_user_role_is_updated', 20, 2 );
}
/* Change the "Verified" badge color */
i.um-verified {
color: #22dd00 !important;
}
/* Set a unique "Verified" badge color for a role */
.um-role-subscriber i.um-verified {
color: #0022dd !important;
}
.um-role-um_member i.um-verified {
color: #dd2200 !important;
}
<?php
/**
* Display the "Request Verification" link.
*
* Example 1: [um_verified_users]
* Example 2: [um_verified_users redirect_to="/user/"]
*
* @param array $attr {
* Attributes of the shortcode.
*
* @type string $redirect_to URL to redirect after request.
* }
* @param string $content Shortcode content.
* @return string HTML content to display the "Request Verification" link.
*/
function um_verified_users_shortcode( $attr = array(), $content = '' ) {
$defaults_atts = array(
'redirect_to' => um_get_core_page( 'account' ),
);
$atts = shortcode_atts( $defaults_atts, $attr, 'um_verified_users' );
if ( ! is_user_logged_in() ) {
return '';
}
$user_id = get_current_user_id();
$verified_status = UM()->Verified_Users_API()->api()->verified_status( $user_id );
wp_enqueue_style( 'um-verified' );
ob_start();
if ( 'unverified' === $verified_status ) {
$verify_url = UM()->Verified_Users_API()->api()->verify_url( $user_id, $atts['redirect_to'] );
?>
<div class="um-verified-info">
<a href="<?php echo esc_url( $verify_url ); ?>" class="um-link um-verified-request-link">
<?php esc_html_e( 'Request Verification', 'um-verified' ); ?>
</a>
</div>
<?php
} elseif ( 'pending' === $verified_status ) {
$cancel_url = UM()->Verified_Users_API()->api()->verify_cancel_url( $user_id, $atts['redirect_to'] );
?>
<div class="um-verified-info">
<?php esc_html_e( 'Your verification request is currently pending.', 'um-verified' ); ?>
<a href="<?php echo esc_url( $cancel_url ); ?>" class="um-verified-cancel-request">
<?php esc_html_e( 'Cancel request?', 'um-verified' ); ?>
</a>
</div>
<?php
}
$content .= ob_get_clean();
return wp_kses_post( $content );
}
if ( function_exists( 'UM' ) && is_plugin_active( 'um-verified-users/um-verified-users.php' ) ) {
add_shortcode( 'um_verified_users', 'um_verified_users_shortcode' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment