Skip to content

Instantly share code, notes, and snippets.

@mahfelwp
mahfelwp / delete_widgets_settings_page_and_link_from_profile_edit.php
Created October 14, 2020 14:27
Delete widgets settings page and link from user dashboard
@mahfelwp
mahfelwp / delet_new_avatar.php
Last active September 30, 2020 14:33
DELETE NEW AVATAR FROM MEDIA AND ACTIVITY TABLE
<?php
function get_all_activity_ids_type_is_new_avatar(){
global $wpdb, $bp;
// Prepare Sql
$sql = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = %s AND component = '%s'", 'new_avatar' , 'profile' );
// Get Result
@mahfelwp
mahfelwp / member_types.php
Created February 6, 2020 19:57
add member types to youzer
<?php
/**
* Register member types.
*
* From the wp-admin/extended profile
* it will be possible to set the user's member type
*/
function using_mt_register_member_types() {
@mahfelwp
mahfelwp / fix_select2.php
Created January 30, 2020 09:09
fix select 2 on theme that conflict with youzer plugin
<?php
function select2_fix() {
if ( is_buddypress() ) { ?>
<script>
jQuery( document ).ready( function($) {
$('select').select2('destroy');
});
</script>
@mahfelwp
mahfelwp / convert.php
Created January 24, 2020 22:01
Convert activity product date to shamsi(jalali) - youzer plugin
<?php
function convert_activity_product_date_to_shamsi($args , $product){
if( ! function_exists('parsidate') || get_locale() != 'fa_IR' ) {
return false;
}
$args['date'] = parsidate("Y-m-d", $product->get_date_created()->format( 'F j, Y' ), "per");
return $args;
@mahfelwp
mahfelwp / parseUrl.js
Last active September 29, 2019 18:18
Simple function for work with Url in Javascript without regxp
// For more information you can see this url: https://developer.mozilla.org/en-US/docs/Web/API/URL
let parseUrl = (url) => {
let parser = document.createElement('a');
parser.href = url;
return parser;
}
let url = parseUrl("http://username:[email protected]:3000/deploy/?search=test#hash");
url.protocol; // => "http:"
<?php
$countries = array (
"افغانستان",
"جزایر آلند",
"آلبانی",
"الجزایر",
"ساموای آمریکا",
"آندورا",
"آنگولا",
"آنگویلا",
@mahfelwp
mahfelwp / get_all_users_id_with_custom_subscription_level.php
Created June 24, 2019 09:22
Get all users id with custom subscription(membership) level
<?php
function get_all_users_id_by_membership_level_id() {
$memberships = rcp_get_memberships( array(
'status' => 'active',
'object_id' => 2 // Membership Levels ID
) );
foreach ($memberships as $membership) {
@mahfelwp
mahfelwp / display_random_vip_users.php
Last active March 30, 2020 14:56
display random vip users (by subscription level on Restrict Content Pro)
<?php
function random_user_query( &$query )
{
$query->query_orderby = "ORDER BY RAND()";
}
function display_random_vip_users( $atts ) {
@mahfelwp
mahfelwp / yz_verified_users_count_shortcode.php
Created June 23, 2019 09:54
Verified users count shortcode in Youzer plugin
<?php
function yz_verified_users_count_shortcode( $atts = null ){
global $wpdb;
// Get Args.
$args = shortcode_atts(
array(
'verified' => 'on',
), $atts, 'yz_verified_users_count' );