New answers tagged

0

To achieve something like that you can make some posts private and show them just to the logged in users, first you need to add a custom field, you can name it "private" and value it "True". Then add replace the default WP loop with this code snippet: <?php if (have_posts()) : while (have_posts()) : the_post(); $private = ...


0

Looks like I found a snippet that do exactly that. It's from Daniel Bachhuber, the API developer. add_filter( 'rest_authentication_errors', function( $result ) { if ( ! empty( $result ) ) { return $result; } if ( ! is_user_logged_in() ) { return new WP_Error( 'restx_logged_out', 'Sorry, you must be logged in to make a request.', ...


0

I discovered that by adding a call to get_currentuserinfo(); in header.php the problem appears to be solved. I still do not know why it happened, but at least this is a working solution for anyone else who happens to have this problem. Note: Following @jgraup's suggestion above, I'm posting this as an answer. However, I am not marking this as accepted ...


1

This isn't really a WordPress question...but instead of re-inventing the wheel take a look at this. I use it in any of my sites where I need to detect mobile device, and it works great. I see on their page they even mention there are WP plugins that use this code.


0

I believe this is now meant to be done using map_meta_cap : For example to block deleting or editing the admin user who has an id of 1 you would do this: add_filter('map_meta_cap', function( $required_caps, $cap, $user_id, $args ){ $protected_user = 1; // ID of admin user you want to block from being edited if ( $user_id === $protected_user ) ...



Top 50 recent answers are included