Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php

Below function works for me by adding !defined(‘DOING_AJAX’) in condition. function custom_blockusers_init() { if ( is_admin() && !defined(‘DOING_AJAX’) && ( current_user_can(‘usercrp’) || current_user_can(‘userpcp’) || current_user_can(‘subscriber’) || current_user_can(‘contributor’) || current_user_can(‘editor’))) { session_destroy(); wp_logout(); wp_redirect( home_url() ); exit; } } add_action( ‘init’, ‘custom_blockusers_init’ );

How to allow Unfiltered HTML in a wordpress multisite install

This had me baffled for a while as well. Not exactly a solution for your problem, but this should get you on your way. add_action( ‘admin_init’, ‘my_kses_remove_filters’ ); function my_kses_remove_filters() { $current_user = wp_get_current_user(); if ( my_user_has_role( ‘administrator’, $current_user ) ) kses_remove_filters(); } function my_user_has_role( $role=””, $user = null ) { $user = $user ? … Read more

Reapproval for edits and deletion after post is published

Let us solve this by going with your second option. So you want to restrict users from editing published posts, this can be done by adding this to your theme’s functions.php file (please read the comments that is added): function restrict_editing_old_posts( $allcaps, $cap, $args ) { // Restrict users from editing post based on the … Read more

Show different badge based upon the user role

You can use get_queried_object to get data in the current author page: <?php $author = get_queried_object(); // uncomment next line to see all author data // print_r( $author ); if( in_array( ‘author’, $author->roles ) ) : echo “author”; elseif( in_array( ‘subscriber’, $author->roles ) ) : echo “subscriber”; endif;

Hide menu items for visitors and filter based on role

You need to define something like this in your header.php file. <?php if ( is_user_logged_in() ) { echo ‘Welcome, registered user!’; } else { echo ‘Welcome, visitor!’; } ?> Create a new role with the following code and put it in your functions.php add_role(‘partners’, ‘Partners’, array( ‘read’ => true, // True allows that capability, False … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)