Redirect returning users to a certain page?

function redirect_user() { if ( is_user_logged_in() ) { wp_redirect( ‘http://yoursite.com/page/’ ); exit; } } add_action( ‘init’, ‘redirect_user’ ); This will redirect the user to the page of your choice if they are logged in. It might be necessary to add a conditional that checks to make sure the user isn’t already on that page, to … Read more

`authenticate` filter never gets called

I can think of a few possibilities, though there certainly could be more. On successful login there is a redirect to the dashboard meaning that if you expect to see something output by that function, you won’t. Try this: add_filter(‘authenticate’, ‘my_authenticate’, 1000, 2); function my_authenticate($user, $username){ var_dump($user, $username); die; // We never arrive in this … Read more

What WP-API authentication method should I use to interact with anonymous / not-logged visitors?

In WP REST API v2 use the permission_callback found in the Adding Custom Endpoints Docs. <?php add_action( ‘rest_api_init’, function () { register_rest_route( ‘myplugin/v2’, ‘/author/(?P<id>\d+)’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘my_awesome_func’, ‘args’ => array( ‘id’ => array( ‘validate_callback’ => ‘is_numeric’ ), ), ‘permission_callback’ => function (WP_REST_Request $request) { if ( current_user_can( ‘edit_others_posts’ ) ) { … Read more

File not found.