Skip to content

Instantly share code, notes, and snippets.

View landbryo's full-sized avatar
🤠
Always Excitied

Landon Otis landbryo

🤠
Always Excitied
View GitHub Profile
/**
* 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,
.idea
.sql
.zip
.tar
.gz
/*
!.gitignore
/**
* 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 );
}
}
add_filter('use_block_editor_for_post', '__return_false');
@landbryo
landbryo / rewrite_url.php
Last active May 27, 2019 17:01
Rewrite image URL for local development
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 February 6, 2019 17:34
Add multiple comment recipients to WordPress
<?php
function comment_recipients( $emails, $comment_id ){
$recipient_email = array(
'[email protected]',
'[email protected]'
);
return $recipient_email;
}
add_filter( 'comment_notification_recipients', 'comment_recipients', 10, 2 );
@landbryo
landbryo / change-howdy.php
Created December 19, 2018 16:37
A function to change the "Howdy" in the WordPress dashboard.
<?php
//////////////////
// CHANGE HOWDY //
//////////////////
function change_howdy( $wp_admin_bar ) {
$my_account = $wp_admin_bar->get_node('my-account');
$newtext = str_replace( 'Howdy,', 'Hi,', $my_account->title );
$wp_admin_bar->add_node( array(
@landbryo
landbryo / comment_emails.php
Created November 19, 2018 17:54
Simple function to change comment recipient emails
//////////////////////////////
// CHANGE COMMENT RECIPIENT //
//////////////////////////////
function override_comment_notice( $emails, $comment_id ) {
$emails = array('[email protected]', '[email protected]');
return $emails;
}
@landbryo
landbryo / enfold-custom-form.php
Last active November 19, 2018 17:57
Customize the from address for Enfold forms.
/////////////////////////////
// ENFOLD FORM CUSTOM FROM //
/////////////////////////////
function avf_form_from_mod($from, $new_post, $form_params) {
$from = "[email protected]";
return $from;
}
//////////////////////////////////////////
// CHANGE DEFAULT WP EMAIL FROM ADDRESS //
//////////////////////////////////////////
function wp_send_email( $original_email_address ) {
return '[email protected]';
}
add_filter( 'wp_mail_from', 'wp_send_email' );
///////////////////////////////////////