list custom taxonomy with count

<?php $taxonomy = ‘judges’; $tax_terms = get_terms($taxonomy); ?> <ul> <?php foreach ($tax_terms as $tax_term) { echo ‘<li>’ . ‘<a href=”‘ . esc_attr(get_term_link($tax_term, $taxonomy)) . ‘” title=”‘ . sprintf( __( “View all shows for %s” ), $tax_term->name ) . ‘” ‘ . ‘>’ . $tax_term->name . ‘(‘ . $tax_term->count . ‘)</a> </li>’; } ?> </ul> Try … Read more

Custom capability for a single user

I solved it myself 🙂 I just added custom capability to the user- $user = new WP_User(1); //1 is the admin ID $user->add_cap( ‘see_encrypted_pass’ ); Then checked- if(current_user_can(‘see_encrypted_pass’)){ //encrypted password } It works!!

How to restrict the amount of categories/post tags/terms for a post type post

Thanks the the replies. I solved my problem with jQuery. Here is the code: jQuery(document).ready(function ($) { $(“#category-tabs li.hide-if-no-js”).hide(); //Hides Most Used tab $(“#category-all input:checkbox”).change(function () { var max = 2; // Max allowed cats var count = $(“#category-all input:checked”).length; //counts selected cats if (count > max) { $(this).prop(“checked”, “”); alert(‘You are only allowed to … Read more

Customize or avoid new admin email address notification

It seems that my edit to your answer was declined, so here you go. All that was missing was the $priority and $accepted_args parameters for the add_action() calls, and the the fixed code below should accomplish what you require. remove_action( ‘add_option_new_admin_email’, ‘update_option_new_admin_email’ ); remove_action( ‘update_option_new_admin_email’, ‘update_option_new_admin_email’ ); /** * Disable the confirmation notices when an … Read more

Import users once a day without a plugin

You can use wp_create_user and pass necessary information like $username, $password, $email , where $email is optional. If user created successfully it will return ID of newly created user, other wise will return error object. Then update user’s other information using update_user_meta.

How to add an attribute to a user?

The easiest trick is to use the user_contactmethods – the fields don’t actually have to be contacts, but WordPress will do all the leg work for you (displaying the fields & saving the data): function wpse_183763_user_contactmethods( $methods, $user ) { $methods[‘my_field_1’] = ‘My Label For Field 1’; $methods[‘my_field_2’] = ‘My Label For Field 2’; return … Read more

Showing user profile data on front-end

You are trying to access the meta data of the user with ID stored in $user->ID but the object $user is not defined in your code. You are also using an undefined variable $user_ID. The quickest fix in your code would be to change this: get_the_author_meta( ‘province’, $user->ID ) ) With: get_the_author_meta( ‘province’, $userdata->ID ) … Read more