Skip to content

Instantly share code, notes, and snippets.

View ronalfy's full-sized avatar
🏠
Working from home

Ronald Huereca ronalfy

🏠
Working from home
View GitHub Profile
@ronalfy
ronalfy / allow-subscribers-user-profile-picture-gutenberg.php
Last active April 7, 2022 21:15
Allow Subscribers in User Profile Picture and Gutenberg
<?php
// For User Profile Picture
add_filter( 'mpp_gutenberg_user_role', function( $role ) {
return 'subscribers';
} );
// For Gutenberg
add_filter( 'rest_user_query', function( $args, $r ) {
if( isset( $args['who'] ) && 'authors' == $args['who'] ) {
$args['who'] = 'subscribers';
@ronalfy
ronalfy / mpp-bp.php
Last active April 6, 2022 03:46
User Profile Picture With BuddyPress
add_filter( 'bp_core_fetch_avatar', 'mpp_bp_avatar', 10, 2 );
function mpp_bp_avatar( $img, $params ) {
// Determine if user has an avatar override
$avatar_override = get_user_option( 'metronet_avatar_override', $params[ 'item_id' ] );
if ( !$avatar_override || $avatar_override != 'on' ) return $img;
$profile_post_id = absint( get_user_option( 'metronet_post_id', $params[ 'item_id' ] ) );
if ( 0 === $profile_post_id || 'mt_pp' !== get_post_type( $profile_post_id ) ) {
@ronalfy
ronalfy / conditional-theme-json.php
Last active March 30, 2022 13:43
Conditionally Load theme.json
<?php
/**
* Conditionally load the default theme.json file.
*
* Assumes directory structure of /theme-name/skins/skin-name/theme.json (see switch statement below).
*
* @package coaching-pro
*/
/**
@ronalfy
ronalfy / gravity-forms-disable-autocomplete.php
Last active March 28, 2022 19:41
Disable autocomplete on the front-end for Gravity Forms
<?php
add_filter( 'gform_form_tag', 'gform_form_tag_autocomplete', 11, 2 );
function gform_form_tag_autocomplete( $form_tag, $form ) {
if ( is_admin() ) return $form_tag;
if ( GFFormsModel::is_html5_enabled() ) {
$form_tag = str_replace( '>', ' autocomplete="off">', $form_tag );
}
return $form_tag;
}
add_filter( 'gform_field_content', 'gform_form_input_autocomplete', 11, 5 );
@ronalfy
ronalfy / directory.php
Created March 2, 2020 14:07
Paid Memberships Pro Directory Customization
<?php
/*
This shortcode will display the members list and additional content based on the defined attributes.
*/
function pmpromd_shortcode($atts, $content=null, $code="")
{
// $atts ::= array of attributes
// $content ::= text within enclosing form of shortcode element
// $code ::= the shortcode found, when == callback name
// examples: [pmpro_member_directory show_avatar="false" show_email="false" levels="1,2"]
@ronalfy
ronalfy / soliloquy-overlay.css
Created May 4, 2016 18:16
Soliloquy Background Overlay
.soliloquy-item:before {
display: block;
content: '';
width: 100%;
height: 100%;
position: absolute;
right: 0;
top: 0;
z-index: 9;
background: #212121;
@ronalfy
ronalfy / pmpro-directory-sort-last-name.php
Last active November 12, 2021 16:21
Paid Memberships Pro Directory Sort by Last Name and First Name
<?php
/**
* Sort the membership directory by lastname first, then first name.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_custom_directory_sql_parts( $parts ) {
@ronalfy
ronalfy / pmpro-add-notes-order-columns-admin-csv.php
Created October 12, 2020 18:07
PMPro - Add Notes to Order Columns in Admin and CSV
<?php
/**
* Adds a notes tab in the admin area and in the order CSV export.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
@ronalfy
ronalfy / pmpro-add-fields-checkout-send-data-zapier.php
Last active October 6, 2021 17:17
Paid Memberships Pro - Add Fields to Checkout and Pass Data to Zapier
<?php
function my_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
// Define the fields.
$fields = array();
$fields[] = new PMProRH_Field(
@ronalfy
ronalfy / pmpro-move-company-bililng.php
Created August 31, 2020 14:14
Paid Memberships Pro - Move Company Field to Billing
<?php
/**
* Move custom company field to the top of the billing information section if it exists.
*/
function pmpro_move_company_to_billing() {
if ( is_page( 'paiement-dadhesion' ) && wp_script_is( 'jquery', 'done' ) ) {
?>
<script>
jQuery( '#company_div' ).prependTo( '.pmpro_checkout-field-bfirstname' );
</script>