Skip to content

Instantly share code, notes, and snippets.

@AngeliMae
AngeliMae / UM Social Activity & Groups discussions - WebP
Created January 2, 2023 16:43
UM Social Activity & Groups discussions - WebP
// Social Activity & Groups discussions
add_filter("um_social_activity_allowed_image_types","um_010223_social_activty_allowed_webp_image_type", 10, 1 );
add_filter("um_groups_discussion_allowed_image_types","um_010223_social_activty_allowed_webp_image_type", 10, 1 );
function um_010223_social_activty_allowed_webp_image_type( $types ){
$types[ ] = "webp";
return $types;
}
@AngeliMae
AngeliMae / UM User Photos Extension - WebP Image File
Last active January 2, 2023 16:41
UM User Photos Extension - WebP Image File
add_filter("um_user_photos_allowed_image_types","um_user_photos_010223_allowed_webp_image_type", 10, 1);
function um_user_photos_010223_allowed_webp_image_type( $arr_types ){
$arr_types[ ] = "image/webp";
return $arr_types;
}
@AngeliMae
AngeliMae / Support WebP in the Image upload - UM Cover & Profile Photo
Last active January 2, 2023 17:24
Support WebP in the Image upload - UM Cover & Profile Photo
// Cover & Profile Photo
add_filter("um_get_field__cover_photo","um_010223_allowed_webp_image_type", 10, 1 );
add_filter("um_get_field__profile_photo","um_010223_allowed_webp_image_type", 10, 1 );
function um_010223_allowed_webp_image_type( $data ){
$arr = explode( ",", $data['allowed_types'] );
$arr[ ] = "webp";
$data['allowed_types'] = implode(",", $arr);
return $data;
@AngeliMae
AngeliMae / gist:a6c79fd595831b08ae8bcb6fd3e94b9b
Created January 2, 2023 14:57
allowed image types in field option for Image field
add_filter("um_allowed_image_types","um_010223_default_allowed_image_types");
function um_010223_default_allowed_image_types( $types ){
$types['webp'] = 'WEBP';
return $types;
}
@AngeliMae
AngeliMae / Use UM Reset Password email when Admin Send Password Reset to User
Created December 14, 2022 12:46
Use UM Reset Password email when Admin Send Password Reset to User
add_filter( 'send_retrieve_password_email', 'send_retrieve_password_email_custom', 10, 3 );
function send_retrieve_password_email_custom( $true, $user_login, $user_data ) {
um_fetch_user( $user_data->ID );
UM()->user()->password_reset();
return false;
}
@AngeliMae
AngeliMae / Stop registration if customer_code field does not equal ABCDE
Last active November 9, 2022 13:07
Stop registration if customer_code field does not equal ABCDE
add_action( 'um_submit_form_errors_hook', 'check_customer_code', 100, 1 );
function check_customer_code( $args ){
if ( isset( $args['customer_code'] ) && $args['customer_code'] != 'ABCDE' ) {
UM()->form()->add_error( 'customer_code', 'Please put in the correcct passcode' );
}
}
@AngeliMae
AngeliMae / Receive email notification when user updates their form
Created September 15, 2022 13:46
Receive email notification when user updates their form
<?php
add_action( 'um_after_user_updated',function( $user_id, $args, $to_update ){
ob_start();
?>
<table>
<tbody>
<?php foreach( $to_update as $metakey => $metavalue ): ?>
<tr>
<th><?php echo $metakey; ?>:</th>
<td><?php echo $metavalue; ?></td>
@AngeliMae
AngeliMae / disable auto-login after registration
Created August 24, 2022 14:35
disable auto-login after registration
add_action( 'um_registration_complete', 'um_registration_complete_custom', 10, 2 );
function um_registration_complete_custom( $user_id, $args ) {
$url = UM()->permalinks()->get_current_url();
exit( wp_redirect( $url ) );
}
@AngeliMae
AngeliMae / send birthday greetings to accounts with today’s birthdays
Created August 8, 2022 12:36
Send birthday greetings to accounts with today’s birthdays
function um_080822_email_notifications( $notifications ){
$notifications['um_greet_todays_birthdays'] = array(
'key' => 'um_greet_todays_birthdays',
'title' => __( 'Happy Birthday!','um-groups' ),
'subject' => 'Happy Birthday from {site_name}',
'body' => 'Hi {display_name},<br /><br />'.
'"We wish you a happy birthday!',
'description' => __('Whether to send the user an email when someone\'s todays birthday.','ultimate-member'),
'recipient' => 'member',
@AngeliMae
AngeliMae / Disable Welcome Email After Registration for Certain Roles
Last active April 20, 2023 11:53
Disable Welcome Email After Registration for Certain Roles
add_action( 'um_before_email_notification_sending', function( $email, $template, $args ) {
if ( 'custom-role-id' === um_user( 'role' ) && 'welcome_email' === $template ) {
add_filter( 'pre_wp_mail', '__return_true' );
}
}, 10, 3 );
add_action( 'um_after_email_notification_sending', function( $email, $template, $args ) {
if ( 'custom-role-id' === um_user( 'role' ) && 'welcome_email' === $template ) {
remove_filter( 'pre_wp_mail', '__return_true' );
}
}, 10, 3 );