Skip to content

Instantly share code, notes, and snippets.

🤠
Big Transition

Landon Otis landbryo

🤠
Big Transition
Block or report user

Report or block landbryo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@landbryo
landbryo / latest_post_menu_item.php
Created Jun 13, 2019
This function looks for the most recent post and adds it to any menu item with #placeholder as a link.
View latest_post_menu_item.php
/**
* Look for placeholder url and replace it with latest post
*
* @param $items
*
* @return mixed
*/
function latest_conference_item( $items ) {
// Get the latest conference
View gravity-field-template
add_filter( 'gform_form_post_get_meta_7', 'add_form_fields' );
function add_form_fields( $form ) {
// Don't make the parent form messy
if ( ! GFCommon::is_form_editor() ) {
// form we are adding fields to
$parent_id = $form['id'];
// template form ID
$childId = 5;
@landbryo
landbryo / custom_set_limit.php
Last active May 1, 2019
A filter to override the Restrict Content Pro - Resume Manager resume limit and set it to a custom value.
View custom_set_limit.php
function custom_set_limit( $at_limit, $user_id ) {
if ( is_user_logged_in() && ! current_user_can( 'administrator' ) ) {
if ( empty( $user_id ) ) {
$user_id = get_current_user_id();
}
$resume_args = array(
'post_type' => 'resume',
View bp_reg_assign_users
/**
* Assign users to groups upon registration
*/
function group_user_activate( $user_id ) {
if ( ! function_exists( 'groups_join_group' ) ) {
return;
}
if ( is_page( 'registration' ) || is_page( 'other-registration' ) ) {
View bp_assignuser_forum
/**
* Assign users to forums upon registration
*/
function sc_user_activate_forum( $user_id ) {
$current_user = get_user_by( 'ID', $user_id );
// Subscribe to forums in listed IDs
if ( groups_is_user_member( $user_id, 7 ) ) {
$forum_ids = array(
997,
1070,
View .gitignore-wordpress
.idea
.sql
.zip
.tar
.gz
/*
!.gitignore
View gf-set-pw
/**
* Set password by field value
*/
function set_password_from_field( $user_id, $feed, $entry, $user_pass ) {
$form_id = rgar( $entry, 'form_id' );
// set field id
if ( '4' === $form_id ) {
wp_set_password( $entry[11], $user_id );
}
}
View disable-gutenberg
add_filter('use_block_editor_for_post', '__return_false');
@landbryo
landbryo / rewrite_url.php
Last active May 27, 2019
Rewrite image URL for local development
View rewrite_url.php
function sc_rewrite_url( $rewrite ) {
$rewrite = str_replace( 'domain.local/wp-content/uploads/', 'domain.com/wp-content/uploads/', $rewrite );
return $rewrite;
}
add_filter( 'wp_get_attachment_url', 'sc_rewrite_url' );
add_filter( 'wp_calculate_image_srcset_meta', function() { return false; } );
@landbryo
landbryo / comment_recipients.php
Last active Feb 6, 2019
Add multiple comment recipients to WordPress
View comment_recipients.php
<?php
function comment_recipients( $emails, $comment_id ){
$recipient_email = array(
'him@example.com',
'her@example.com'
);
return $recipient_email;
}
add_filter( 'comment_notification_recipients', 'comment_recipients', 10, 2 );
You can’t perform that action at this time.