According to your functions, if you want to redirect users when they are visiting the website’s homepage. You could implement the is_front_page() function to detect and only redirects if they are on the frontpage.
function user_homepage() {
if ( is_user_logged_in() ) {
$args = array(
'field' => 25,
);
$user_homepage = bp_profile_field_data( $args );
if ( is_front_page() ) {
if ($user_homepage == 'Sports') {
$redirect_to = home_url('/sports/');
wp_redirect( $redirect_to );
exit;
}
else if ($user_homepage == 'Tech') {
$redirect_to = home_url('/tech/');
wp_redirect( $redirect_to );
exit;
}
}
}
}
add_filter('login_redirect','user_homepage',10,3);
Related Posts:
- Is it safe to store a user setting you don’t want the user to ever modify as a user option?
- How to get users by a custom field / by user meta data?
- How do you add a custom option to user data?
- Custom user avatar in the WordPress users listing
- User Profile / Add Custom Fields
- Redirect after User Activation [closed]
- Show User Their Password
- Create additional short URL with custom field and 301 redirect
- Adding Properties to User Profile and Displaying in List
- How can I sort get_users() by any value (last_name, user defined fields and more)
- Using a custom field value to redirect away from a 404 page
- Extra filed under “About the user” user profile
- get_user_meta Short Profile Section
- Importing users to Buddypress with custom fields
- BuddyPress – Hook to Update Custom Profile Fields [closed]
- Custom User Profile Fields
- Add More Fields to Users Pages (Admin Panel)
- Register rest field for specific user
- Masking Affiliate URL using $post_slug after “/go/”
- Buddypress Add unserialized Profile Fields in Members Loop [closed]
- WordPress User Profile Upload – If page is saved file reset
- How to show a gloabl message on a user profile page (in back end)?
- WP_User_Query pulling ACF to loop
- Custom Fields – Taller editing area
- Front-end editing with custom fields?
- Excluding Specific Fields from Profile Builder Registration Form
- Custom Profile Fields move from BBpress to BuddyPress
- Passing args to WP_User_Query am I using meta correctly?
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Customizing user data
- Linking Custom Fields to Database Records
- Multiple URLS per post non-ascii
- Show user info in a hovercard [closed]
- Customizing WP user profile with custom fields
- Iterate through users and display users meta info at front-page
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- check for duplicate user meta data before updating
- Custom Field Repeating When Using foreach
- How to redirect to home page according to a specific page custom fields value and user name
- Front end register with custom fields
- Front-End User Profile
- Get emails from users by custom field SQL
- redirect user to their profile after log in
- Save custom field types with this function…?
- How to parse a huge list of users using a CRON function?
- Adding data to User profile
- Delete user meta but only if found in array
- Very large list of options for BuddyPress profile fields
- How to save multiple custom user profile fields using repeater JQuery
- Link fields in User Admin list
- Redirecting to an external URL
- Extend WP_User_Query or WP_User to return all custom fields?
- How to keep sharing stats after creating 301 redirects?
- Echo text if field under user_meta is empty with get_users()
- Semi-Private Comments + page comments -> is it possible?
- file upload user profile
- Problem with serialized arrays in custom meta
- explode array within shortcode
- Can I count the number of users matching a value in a multiple value key?
- How to delete custom field “suggestions” from dropdown list
- How to get a meta value from all post
- Adding existing user custom field value to a woocommerce product [closed]
- How to save values of a custom input field on the Network > Site Info screen
- ajax jquery update custom field meta value front end
- get_post_meta not working inside loop
- How do I exclude posts by custom field value?
- Orderby custom field meta value ASC and then by date DESC
- Creating author profiles with extra fields and exporting that data?
- WP_User_List -> How to open a new edit-page in WordPress admin backend!
- Better way to save image in custom field
- Removing link ” from ” on meta_value in custom feilds
- Jetpack post types Portfolio or Testimonials support for custom fields?
- How to add a custom field in the advanced menu properties?
- filter custom field values $min $max
- Custom Fields – How to create a list from multi-line entries of a single value
- custom field (video/audio url) and embed functionality
- Querying posts by latitude and longitude to build a Google Maps with several markers
- How to display childrens custom fields?
- Displaying pages with a specific custom meta
- How to update user profile custom fields
- How to validation for sanitize_URL?
- How can I output the custom fields wrapping with HTML
- put saved metabox values back into fields and then display on the front end
- How to get custom image field of specific post id
- Custom field to array?
- How to update custom field of a posts in a particular category
- How to query posts by month based on date custom field?
- Change word in woocommerce product category custom field
- get posts based on non-single metadata
- Woocommerce products search with custom fields
- Convert author metadata to a custom field
- Custom pages or Custom Posts
- get_avatar filter is not working as per requirement
- WordPress Admin – Automatically Sort Custom Posts by Custom Field Date Value in d-m-Y Fomat
- searching by keywords in post’s metas or pagination links problem
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- Retrieve Google API JSON data and store as WordPress Custom Fields
- meta_query ‘compare’ => ‘!=’ not working
- Display Data From This Custom Media Upload Meta Box?
- Pagination not displaying correct number of pages