Category: Admin
GForms – Signature – Update Signature Merge Tag Value to Display HTML img using ‘:img’
add_filter( ‘gform_merge_tag_filter’, ‘signature_to_img’, 10, 6); function signature_to_img( $value, $merge_tag, $modifier, $field, $raw_value, $format ) { if ( $field->type == ‘signature’ && $modifier == ‘img’ ) { return ‘‘; } return $value; }Continue reading
GFlow – Notification Step – Attach Uploaded Files to GFlow Notification Steps – Specific Form Only
add_filter( ‘gravityflow_notification’, ‘sh_gravityflow_notification’, 10, 4 ); function sh_gravityflow_notification( $notification, $form, $entry, $step ) { //ONLY ATTACH ON SPECIFIC FORMS, NOT ALL if ( $form[‘id’] != 34 ) { //34 = Client Email Notice return $notification; } $log = ‘sh_notification_attachments() –…Continue reading
GForms – Add {created_by:roles} merge tag to return comma separated list of roles
/* Source: https://docs.gravityforms.com/gform_merge_tag_data/ */ add_filter( ‘gform_merge_tag_data’, function ( $data, $text, $form, $entry ) { $data[‘created_by’] = array(); if ( ! empty( $entry[‘created_by’] ) ) { $user = new WP_User( $entry[‘created_by’] ); $data[‘created_by’] = get_object_vars( $user->data ); $data[‘created_by’][‘first_name’] = $user->get( ‘first_name’…Continue reading
GFlow – Workflow Notification – Replace Custom Send to Merge Tags {send_to[first_name,roles,etc.]}
//Works for any Step’s Workflow Notifications // Custom Merge Tags to retrieve info about the user with the corresponding ‘to’ // email in the GFlow Notification // A GFlow notification’s ‘to’ contains the list of emails the notification will be…Continue reading
GForms – Add noclasshidden modifier to {all_fields} merge tag
add_filter( ‘gform_merge_tag_filter’, ‘filter_all_fields_hide’, 10, 4 ); function filter_all_fields_hide ( $value, $merge_tag, $modifier, $field ) { if ( $merge_tag == ‘all_fields’ && str_contains( $modifier, ‘noclasshidden’ ) && str_contains( $field->cssClass, ‘all-fields-hide’ ) ) { return false; } return $value; }Continue reading
Require User Login for Archive Pages
add_action( ‘template_redirect’, function () { if ( is_archive() && ! is_user_logged_in() ) { auth_redirect(); } } );Continue reading
WP Admin – Update Admin Footer Text
add_filter( ‘admin_footer_text’, ‘afm_update_admin_footer_text’ ); // Footer Left text (Originally ‘Thank you for creating with WordPress’) function afm_update_admin_footer_text( $text ) { return sprintf( ‘Thank you for using the COAST Client Portal.’, esc_url( ‘https://nowcoast.com/’ ) ); } //Footer Right text (Originally displays…Continue reading
WP Admin – Replace WP Logo from Admin Bar
// Update Image src and alt text to match site add_action(‘admin_bar_menu’, ‘afm_replace_admin_bar_wp_logo’, 11); function afm_replace_admin_bar_wp_logo($wp_admin_bar) { $wp_admin_bar->remove_menu( ‘about’ ); $wp_admin_bar->remove_menu( ‘contribute’ ); $wp_admin_bar->remove_menu( ‘wporg’ ); $wp_admin_bar->remove_menu( ‘documentation’ ); $wp_admin_bar->remove_menu( ‘learn’ ); $wp_admin_bar->remove_menu( ‘support-forums’ ); $wp_admin_bar->remove_menu( ‘feedback’ ); $wp_admin_bar->remove_menu( ‘wp-logo’ );…Continue reading
WP Admin – Remove sections from User Profile for non-admin, editor
// Remove Color Scheme Picker add_action( ‘admin_head-profile.php’, ‘afm_remove_color_scheme’ ); function afm_remove_color_scheme( ) { $user = wp_get_current_user(); $allowed_roles = array( ‘administrator’, ‘editor’ ); if ( ! array_intersect( $allowed_roles, $user->roles ) ) { remove_action( ‘admin_color_scheme_picker’, ‘admin_color_scheme_picker’ ); } } // Remove application…Continue reading