Skip to content

Instantly share code, notes, and snippets.

View cryptexvinci's full-sized avatar
🏆
Focusing

Towhid cryptexvinci

🏆
Focusing
  • Ultimate Member Group Ltd
  • Bangladesh
View GitHub Profile
@cryptexvinci
cryptexvinci / um-user-review.php
Created September 30, 2019 02:17
Allow multiple user reviews.
/* Allow multiple reviews */
add_filter( 'um_reviews_allow_multiple_reviews', '__return_true' );
@cryptexvinci
cryptexvinci / um-field-validation-iban.php
Last active September 22, 2021 00:09
IBAN Field validation
<?php
function checkIBAN($iban) {
$iban = strtolower(str_replace(' ','',$iban));
$Countries = array('al'=>28,'ad'=>24,'at'=>20,'az'=>28,'bh'=>22,'be'=>16,'ba'=>20,'br'=>29,'bg'=>22,'cr'=>21,'hr'=>21,'cy'=>28,'cz'=>24,'dk'=>18,'do'=>28,'ee'=>20,'fo'=>18,'fi'=>18,'fr'=>27,'ge'=>22,'de'=>22,'gi'=>23,'gr'=>27,'gl'=>18,'gt'=>28,'hu'=>28,'is'=>26,'ie'=>22,'il'=>23,'it'=>27,'jo'=>30,'kz'=>20,'kw'=>30,'lv'=>21,'lb'=>28,'li'=>21,'lt'=>20,'lu'=>20,'mk'=>19,'mt'=>31,'mr'=>27,'mu'=>30,'mc'=>27,'md'=>24,'me'=>22,'nl'=>18,'no'=>15,'pk'=>24,'ps'=>29,'pl'=>28,'pt'=>25,'qa'=>29,'ro'=>24,'sm'=>27,'sa'=>24,'rs'=>22,'sk'=>24,'si'=>19,'es'=>24,'se'=>24,'ch'=>21,'tn'=>24,'tr'=>26,'ae'=>23,'gb'=>22,'vg'=>24);
$Chars = array('a'=>10,'b'=>11,'c'=>12,'d'=>13,'e'=>14,'f'=>15,'g'=>16,'h'=>17,'i'=>18,'j'=>19,'k'=>20,'l'=>21,'m'=>22,'n'=>23,'o'=>24,'p'=>25,'q'=>26,'r'=>27,'s'=>28,'t'=>29,'u'=>30,'v'=>31,'w'=>32,'x'=>33,'y'=>34,'z'=>35);
if(strlen($iban) == $Countries[substr($iban,0,2)]){
$MovedChar = substr($iba
@cryptexvinci
cryptexvinci / um-format-phone.php
Last active February 28, 2023 05:41
Ultimate Member - get phone numbers to auto-format.
<?php
add_filter('um_profile_field_filter_hook__phone_no', 'um_profile_field_filter_hook__phoneno', 99, 2);
function um_profile_field_filter_hook__phoneno( $value, $data ) {
$value = do_shortcode( $value );
return preg_replace( '/([0-9]{2})([0-9]{4})([0-9]{4})/', '$1-$2-$3', $value );
}
@cryptexvinci
cryptexvinci / um-login-redirect.php
Last active December 2, 2020 01:52
Login Redirect from Comments
<?php
/**
* Ultimate member - Redirect Comment to UM Login page on “You must be logged in to post a comment”.
* URL: https://wordpress.org/support/topic/email-domain-restriction-at-registration/
*/
// Change Default Comment Login link to UM Login Page.
add_filter( 'comment_form_defaults', 'um_change_login_link' );
if ( ! function_exists( 'um_change_login_link' ) ) {
function um_change_login_link( $defaults ) {
@cryptexvinci
cryptexvinci / um-field-value-shortcode.php
Last active April 29, 2020 16:23
Display Ultimate Member field with a shortcode.
<?php
/*
Code snippet of Plugin Ultimate Member
URL: https://wordpress.org/plugins/ultimate-member/
*/
// Display field data of Ultimate Member
// e.g. [um_field_data userid="10' field="company_name"]
add_shortcode( 'um_field_data', 'um_custom_field_shortcode' );
@cryptexvinci
cryptexvinci / custom-woocommerce-review-author.php
Last active October 12, 2020 04:50
Displaying "First initial of first name & last name" for my buying customers that gave a review for privacy purpose.
<?php
add_filter( 'comment_author', 'custom_comment_author', 10, 2 );
function custom_comment_author( $author, $commentID ) {
$comment = get_comment( $commentID );
$user = get_user_by( 'email', $comment->comment_author_email );
if( ! $user ) {
@cryptexvinci
cryptexvinci / um-post-restriction.php
Created May 30, 2019 09:13
UM Individual Post Restriction
global $post;
$restriction = get_post_meta( $post->ID, 'um_content_restriction', true );
// if the post is restricted do this.
if ( $restriction['_um_accessible'] == 2 ){
// do this.
}
@cryptexvinci
cryptexvinci / age-restriction.php
Last active February 28, 2023 05:43
Ultimate Member - Age limit registration
<?php
add_action('um_submit_form_errors_hook_', 'um_custom_validate_birthdate', 999, 1);
function um_custom_validate_birthdate($args) {
$birthDate = isset($args['birth_date']) ? $args['birth_date'] : '';
// Validate input format
if (!strtotime($birthDate)) {
UM()->form()->add_error('birth_date', "Invalid date format.");
return;
@cryptexvinci
cryptexvinci / um-upload-video.php
Last active February 23, 2022 15:27
Extend Ultimate Member File Upload types
<?php
/**
* Issue: Cannot upload video using file upload form fields – no mp4 option!
* @since 2019-05-21
*/
function um_add_more_allowed_file_types( $allowed_types ) {
if( is_array( $allowed_types ) ) {
$allowed_types = array_merge( array(
'3gp' => '.3gp - 3GPP video',
@cryptexvinci
cryptexvinci / um-width-limit.php
Last active February 28, 2023 05:45
Ultimate Member - Need to change image upload minimum width limit.
<?php
add_filter( 'um_image_handle_global__option', function( $data ) {
$data['min_width'] = 300;
$data['min_height'] = 300;
return $data;
} );