Skip to content

Instantly share code, notes, and snippets.

View hayskytech's full-sized avatar

Sufyan Haysky hayskytech

View GitHub Profile
@hayskytech
hayskytech / upi-html-link.html
Last active March 2, 2023 07:26
UPI-HTML-Link
<?php
add_action( 'wp_enqueue_scripts',function(){
global $post;
if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'mathematics_exam') ) {
wp_enqueue_script( 'jquery');
}
});
<?php
add_filter('manage_users_columns','remove_users_columns');
function remove_users_columns($column_headers) {
// if (current_user_can('moderator')) {
unset($column_headers['name']);
// }
return $column_headers;
}
<?php
/*** Sort and Filter Users ***/
add_action('restrict_manage_users', 'filter_by_gender');
function filter_by_gender($which){
// template for filtering
$st = '<select name="gender_%s" style="float:none;margin-left:10px;">
<option value="">%s</option>%s</select>';
// generate options
<?php
add_action( 'init', function() {
if ( is_admin() && ! current_user_can( 'administrator' ) && is_user_logged_in() && ! wp_doing_ajax() ) {
wp_redirect( home_url().'/account' );
exit;
}
});
@hayskytech
hayskytech / hide_adminbar.php
Last active August 20, 2022 00:58
WP Hide Admin Bar for non-admin
<?php
function haysky_disable_admin_bar() {
if (current_user_can('administrator') ) {
show_admin_bar(true);
} else {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'haysky_disable_admin_bar');