New answers tagged


add_action('init', function(){ $redirect = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : home_url( '/' ); $user = wp_get_current_user(); if ( !defined('DOING_AJAX') && in_array( 'subscriber', (array) $user->roles ) ) { wp_redirect($redirect); exit(); } });


I spent two days searching for a simple way without adding plugins. first in function.php where you define your api //enqueue the script which will use the api function api_callings_scripts() { wp_enqueue_script('score-script', get_template_directory_uri() . '/js/ScoreSaving.js', ['jquery'], NULL, TRUE); // Pass nonce to JS. wp_localize_script('...


Post types in WordPress have a list of capabilities that govern permissions surrounding them. These are: edit_post read_post delete_post edit_posts edit_others_posts publish_posts read_private_posts read delete_posts delete_private_posts delete_published_posts delete_others_posts edit_private_posts edit_published_posts create_posts Internally each post ...


this parameter should work for this 'publish_pages' => false,


Expanding on Raja's answer you could also write a helper function that handles this for you: <?php # This goes in functions.php function get_users_by_role($role, $orderby, $order) { $args = array( 'role' => $role, 'orderby' => $orderby, 'order' => $order ); $users = get_users( $args ); return $users;...


Custom Post Types will be much easier to set up, and you won't have to code your own solution to check in the Editor whether the current user has permission to create a new page or edit something. You can set up the CPT archives at whatever URL you like. So, in your example, you can set up a regular Page at /animals/ and a regular child Page at /animals/...

Top 50 recent answers are included