Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
KaineLabs / yzc_fix_frontend_submission_editor.php
Created November 13, 2024 17:41
Youzify - Fix Enfold Theme "Add Media" Button
<?php
/**
* Youzify - Fix Enfold Theme "Add Media" Button
* */
function yzc_fix_frontend_submission_editor( $default ) {
if ( bp_current_component() ) {
return 'force_mediaelement';
}
<?php
// Enable Block Based Theme Template
function yzc_override_youzify_template_using_block_based_template() {
ob_start();
wp_head();
@KaineLabs
KaineLabs / storio_custom_upload_mimes.php
Created September 20, 2024 08:03
Storio - Extend Stories Plugin Upload Extensions
<?php
// Storio - Extend Stories Plugin Upload Extensions
add_filter('upload_mimes', 'storio_custom_upload_mimes');
function storio_custom_upload_mimes($mimes) {
$custom_mime_types = array(
'json' => 'application/json',
'xml' => 'application/xml',
'txt' => 'text/plain',
'avif' => 'image/avif',
'gif' => 'image/gif',
@KaineLabs
KaineLabs / fix-youzify-vikinger-compatibility.php
Created July 16, 2024 18:16
Fix Vikinger Theme and Youzify Compatibility
<?php
function vikinger_members_remove_unused_subnav_items() {
// Override Vikinger Function
}
function vikinger_groups_remove_unused_subnav_items() {
// Override Vikinger Function
}
@KaineLabs
KaineLabs / yzc_custom_validate_username.php
Last active June 16, 2024 09:29
Youzify - BuddyPress Validate Username with Latin Characters
<?php
// Function to validate username with Latin characters
function yzc_custom_validate_username($valid, $username) {
// Allow Latin characters and numbers
if (preg_match('/^[a-zA-Z0-9ñÑáéíóúÁÉÍÓÚüÜ]*$/', $username)) {
return true;
}
return $valid;
}
@KaineLabs
KaineLabs / _yz_show_pin_tool.php
Created May 24, 2024 08:22
Youzify - Make non admins Pin/Unpin Posts.
<?php
// Make non admin able to pin/unpin posts
function _yz_show_pin_tool(){
$pin = ['administrator'];
if( !current_user_can('administrator') ){
$pin = ['administrator', 'shop_manager'];
}
return $pin;
}
add_filter('youzify_allowed_roles_to_pin_posts', '_yz_show_pin_tool', 10 );
@KaineLabs
KaineLabs / filter_activity_stream_by_category.php
Created May 3, 2024 14:47
BuddyPress - Exclude Posts From The Activity Stream by Category
<?php
// Exclude posts from the activity stream by category
function filter_activity_stream_by_category($where_conditions, $select_sql, $from_sql, $join_sql, $where_sql) {
// Get the term ID for the parent category 'your-category-slug'
$parent_category_id = get_cat_ID('your-category-slug'); // Change 'your-category-slug' to the slug of the category you would like to exclude and all it's subcategories
// Get all child category IDs of 'category-slug'
$child_categories = get_term_children($parent_category_id, 'category');
$child_categories_ids = array_map('intval', $child_categories); // Ensure they are integers
@KaineLabs
KaineLabs / yzc_force_strong_password.php
Created May 3, 2024 14:45
BuddyPress - Force Users to add Strong Password
<?php
add_filter( 'bp_members_validate_user_password', function ($errors, $pass ) {
if ( $errors->has_errors() ) {
return $errors;
}
$uppercase_exp = '/[A-Z]/';
$lowercase_exp = '/[a-z]/';
$special_char_exp = '/[!@#$%^&*()-_=+{};:,<.>]/';
$numeric_exp = '/[0-9]/';
@KaineLabs
KaineLabs / custom_youzify_get_attachment_image_size.php
Created February 29, 2024 10:30
Youzify - Change image size thumbnail "Upload New Avatar Post Status Type"
<?php
add_filter('youzify_get_attachment_image_size', 'custom_youzify_get_attachment_image_size', 999,
2);
function custom_youzify_get_attachment_image_size($size, $element) {
if ($element == 'activity-avatar-image') {
$size = 'full';
}
return $size;
}
@KaineLabs
KaineLabs / yzc_notify_users_on_activities.php
Created February 29, 2024 10:28
BuddyPress - Youzify Send email notifications to All users if there's a new posts
<?php
/**
* Youzify - BuddyPress Notify Users on New Activities.
*/
add_action( 'youzify_after_adding_wall_post', 'yzc_notify_users_on_activities', 999 );
function yzc_notify_users_on_activities( $activity_id ) {
$subject = "New activity posted!";
$message = 'New activity has been posted, please visit ' . bp_activity_get_permalink( $activity_id );
// Get all users.