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
- How to hide a field on the frontend of a Buddypress page by field ID according to user roles and login status?
- Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
- WP_Query – Order results by meta value
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- getting all values for a custom field key (cross-post)
- How to add a custom field in the advanced menu properties?
- Custom query with orderby meta_value of custom field
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Using meta query (‘meta_query’) with a search query (‘s’)
- Can I exclude a post by meta key using pre_get_posts function?
- Add validation and error handling when saving custom fields?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Show Custom Fields in Quick Edit
- Admin Page Redirect
- Where are custom field values stored in the database
- Validating Custom Meta Box Values & Required Fields
- Max length of meta_value
- Add custom fields to wp native gallery settings
- How to fix missing custom fields after upgrading to WordPress 4.8.1?
- How to enable custom fields for pages (if not a bad practice)?
- How can I add extra attribute in the ‘Page Attribute’ section in wp-admin for pages?
- Is there a way to set default custom fields when creating a post?
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Custom field/meta populated by dropdown of existing posts?
- Difference between meta keys with _ and without _ [duplicate]
- Is there any action filter/hook for validating a custom field before publishing the post?
- Remove Dimension from wp_get_attachment_image
- Orderby meta_value only returns posts that have existing meta_key
- Underscores in custom fields
- What is the index [0] for on post meta fields?
- What is “meta_input” parameter in wp_insert_post() used for?
- Query Posts or Get Posts by custom fields, possible?
- How to enable revisions for post meta data?
- Sortable Custom Columns in User Panel (users.php)?
- Any way to add custom options to Gallery Settings?
- The “_encloseme” Meta-Key Conundrum
- ORDER BY custom field value
- Individual Widgets per Page
- Add subtitle to Woocommerce product title
- Best way to programmatically remove a category/term from a post
- Importing data for advanced custom fields plugin?
- Gutenberg add a custom metabox to default blocks
- SQL Query to copy value of a meta_key into another meta_key