To get the permalink of a users most recent post (of custom post type) perform the following query:
$latest = get_posts(array(
'author' => $current_user->ID,
'orderby' => 'date',
'post_type' => 'my_custom_post_type',
'order' => 'desc',
'numberposts' => 1,
));
if( $latest ) {
$url = get_permalink($latest[0]->ID);
} else {
// No posts
}
For the redirect part take a look at the function wp_redirect.
Related Posts:
- Redirect after User Activation [closed]
- Redirecting user after updating profile?
- Redirect User to Homepage if no other redirect is specified
- Redirect after users complete profile form
- Rule to redirect non logged in User to Custom Registration/login Page in .htaccess file
- Redirect user to login before viewing custom post
- Redirect subscribers to last viewed page after log-in
- Redirect user after successful email change
- WP_User_List -> How to open a new edit-page in WordPress admin backend!
- How to stop redirect if user is already on correct page (Using Case Switch)
- WP not logging in at first time
- How to check User Role and redirect to specific page according to Role when login in WordPress?
- How can I do a url redirect to include a wordpress username?
- Redirect logged on user to a specific page based on wp user role, page id
- Redirect users after login
- Redirect user to login if not logged in, on specific pages
- redirect user to their profile after log in
- WordPress Redirect Specific User. Tired of Peter’s redirect Plugin its not working
- how redirect users to custom login page when “login to reply” is clicked? [duplicate]
- How to remember which page the user was on before logout?
- Redirect /member/ to /member/user
- Specific Content on pages based on user
- Redirect current user
- Redirect based on log-in status per JavaScript
- Redirect user based on role when they try access a particular page
- Find out if logged in user is not subscriber
- User-edit role setting distinct from wp_capabilities? [closed]
- Delete all subscribers from wp_users and wp_usermeta a few thousand at a time
- Hide Admin Menu for Specific User ID who has administrator Role
- Problem with Hebrew characters in username
- Allowing an email as the username?
- Get the name of user who updated post
- Disable delete user
- Send activation email to user after signup [duplicate]
- wp_update_user() does not update user_data
- How to add follow functionality to multi-author wordpress site?
- Search multiple meta keys at once
- How to add new custom field in default add user form through plugin
- ACF Upload Image in front-end with custom form
- Can I bulk register contributors for a new blog
- show cimy user fields in users.php with manage_users_columns
- Why i getting blank user_activation_key in get_user_by( ‘login’, $login ) function?
- how do i get a greeting for logged in uses by the time of day
- Multiple authors with different “author roles”
- Exclude subscriber users from user list
- How can i create an array user meta?
- How can I check if a user’s email exists in the database
- Getting users by specific capability, not role
- Creating user in Firebase after WordPress user registration
- How to display total number of post done by user, it should display at authors page wordpress [duplicate]
- When I try to login in wordpress it is showing “USER Doesn’t Exists”
- Delete User via Frontend
- Limit a number of users returned from sorting users by latest posts function
- Will wordpress tools import do everything I need to copy one site to another
- OAuth 2 and saving the authenticated user
- Accessing current users data within a plugin
- How to notify specific users when i’m posting/modifying a new post
- User description only displayed for logged user
- Fetch all data of Users
- Allow users to create post without logging in?
- How to get the count
- WordPress Password security related questions
- Assign random (and unique) user meta upon registration
- How do you manage your pages or functions that require logged-in users?
- Display the line breaks in user bio without using html
- Querying specific table row by current user login
- How to make current user’s avatar + display name link to their profile?
- Import users once a day without a plugin
- wp_dropdown_users() to include null value
- Adding more fields to the add user page on dashboard
- Using get_user in wordpress with sorting
- How can I add authors in WordPress and assign them a picture?
- wp_generate_password sets password but can’t login using created password
- Janrain/Simple Modal under Redirected Domain
- How to verify which WordPress user requested the API in ASP .NET Core?
- Get users meta and show to attribute
- How can admins to be notified of changes when users change their WP profiles?
- Custom Password Reset
- Can I add a unique code for each user based on the location?
- wp-admin/users.php Add a column with last name
- Is nicename the same as nickname in WP?
- 502 Error when edit some users
- How to update a user with REST API v2 knowing only the username?
- get_users – Sort by a different meta_value than search criteria
- How to prevent deleteting specific user?
- Display recent members
- To save user info on the same page by form submiting
- Groups roles & capabilities
- Button for users to upgrade their user role + Button to show current user role!
- How do I Limit the number of pages a non-subscriber can see?
- Retrieve New user’s ID
- Restrict access to certain dashboard pages based on user id
- how to show logged in members username in wordpress content
- How to expire guest users after 1.5 hours logged in?
- User agent stylesheet distorting site [closed]
- WordPress – Security Question at Login from User’s Meta Data
- determine active user browser at the same time
- get Discussion setting in wordpress
- Set a minimal number for next user_id
- Remove My Account Menu items in Woocommerce based on user roles