Skip to content

Instantly share code, notes, and snippets.

View codezz's full-sized avatar
🎯
Focusing

Gabriel F. codezz

🎯
Focusing
View GitHub Profile
@codezz
codezz / pmpro-buddypress-registration-membership-level.php
Last active December 20, 2018 12:34
Paid Memberships Pro and Buddypress snippet to add a member to a specific Membership level based on user profile field completed at registration
<?php
/**
* When registering, add the member to a specific membership level
* based on the field value he gas selected
*
* @global object $wpdb
* @global object $bp
* @param integer $user_id
*/
ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver_timeout 5s;
add_filter( 'user_contactmethods', 'svq_update_contactmethods', 10);
function svq_update_contactmethods($contact_methods) {
// Add Twitter.
$contact_methods['profession'] = __( 'Profession title', 'seeko' );
$contact_methods['twitter'] = __( 'Twitter username (without @)', 'seeko' );
// Add Facebook.
$contact_methods['facebook'] = __( 'Facebook profile URL', 'seeko' );
// Add LinkedIn.
$contact_methods['linkedin'] = __( 'LinkedIn URL', 'seeko' );
@codezz
codezz / rewrite-rule-for-dynamic-subpages.php
Created December 20, 2018 12:30
Rewrite rule for dynamic subpages
<?php
// allow WP to store querystring attribs for use in our pages
function sq_query_vars_filter($vars) {
$vars[] = 'user_name';
$vars[] .= 'user_page';
return $vars;
}
add_filter( 'query_vars', 'sq_query_vars_filter' );
jQuery(document).ready(function() {
jQuery('#buddypress').on( 'click', '.pagination-links a', function() {
window.history.pushState(null, null, jQuery(this).attr('href'));
});
});
@codezz
codezz / woo-homepage-control.php
Created April 15, 2019 07:25
Kleo theme woocommerce homepage hook
<?php
/**
* Template Name: WooThemes HomePage control plugin
*
* Description: For Homepage Control plugin only
*
* @package WordPress
* @subpackage Kleo
* @author SeventhQueen <themesupport@seventhqueen.com>
* @since Kleo 1.0
// add this to sweetdate-child/functions.php
if ( ! function_exists( 'compatibility_score' ) ) {
/**
* Calculate compatibility between members based on their profiles
*
* @param int|bool $userid1
* @param int|bool $userid2
*
* @return int
@codezz
codezz / kleo-search-form-tags.php
Last active August 7, 2019 12:17
KLEO Search form - allow searching in post tags
<?php
add_filter( 'kleo_ajax_query_args', function ( $args ) {
// load the terms using LIKE search
$term_ids = get_terms( [
'name__like' => $_REQUEST['s'],
'fields' => 'ids',
'taxonomy' => 'post_tag',
'hide_empty' => true
] );
@codezz
codezz / bp-name-to-username.php
Created August 30, 2019 13:59
Display BuddyPress usernames instead of name all over the buddypress site
<?php
add_filter( 'bp_get_member_name', function( $name ) {
global $members_template;
if ( ! empty( $members_template->member->user_login ) ) {
return $members_template->member->user_login;
}
return $name;
});
add_filter( 'bp_displayed_user_fullname', function( $name ) {
@codezz
codezz / bp-username-to-name-messages.php
Created November 15, 2020 16:36
BuddyPress Nouveau Template - Change username to name in messages interface
<?php
add_action( 'wp_ajax_messages_get_user_message_threads', 'stax_bpb_change_messages_username', 9 );
function stax_bpb_change_messages_username() {
add_filter('bp_core_get_username', function( $name ) {
$user = get_user_by('login', $name);
if ($user) {
$name = $user->display_name;
}
return $name;
});