Thanks to Kaiser for pointing me in the right direction:
I scrapped the agents_permalinks function and went for this for the redirect and it works as intended:
wp_redirect (home_url('agents/agent-profile/' . ($user_id))); exit;
Related Posts:
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- How do I get the permalink of a custom post type?
- Shouldn’t this be easy?! Custom post type/custom taxonomy permalink
- WordPress 3.3 custom post type with /%postname%/ permastruct?
- Custom Post type & Taxonomy URL structure
- Combining Multiple Taxonomies in one URL
- Custom post types – Use post_id in permalink structure when using has_archive => true
- Taxonomy term in permalink
- Custom Post Type Archives by Date with Custom Permalink
- ‘publicly_queryable’ => false not working as expected for custom post_type
- Why does a custom post type need the ”hierarchical’ args setting?
- Modify custom post type rewrite rules in a separate function
- Redirect after deleting post and keep track of pagination
- Slug for custom post type archive
- Permalink rewrite with custom post type and custom taxonomy
- Permalinks in Custom Post types
- Custom Post Type with Nested Taxonomy and Template Files
- Custom Permalinks for Custom post Type Archives?
- Change the url of Projects in Divi Theme
- Semantic URL Custom Post Type and Taxonomies permalinks
- Disable WordPress Recognizing Path as Attachment
- Passing parameters to WordPress static front page
- Add hierarchical taxonomy to permalink for custom post type
- Possible for Category Base and Custom post Type to share the same slug/permalink?
- How much control do we have over CPT rewrite slugs? Can I create a “root” page for my CPT with out the page path, and then have paths for other pages?
- Removing parent slug in hierachial custom post type
- Wrong generated page_name/slug on first publish of custom post type
- Stop / prevent WordPress from updating permalinks of custom post type
- How do I correct an incorrect permalink?
- Update permalinks when new category added to custom post type taxonomy
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- Why doesn’t a custom post type permalink ever hit index.php
- Allow post/page hierarchy across different post types?
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- custom-taxonomy/post_name instead of the default post_type/post_name
- Show custom post archive when custom post not specified
- Show custom post type relationships by taxonomy
- Custom Permalink to remove category word , keeping posts permalink with date?
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- Custom Post Type Permalink
- Permalinks for custom post type
- How to include term custom meta into the custom taxonomy term permalink structure
- Custom Post Fields at the beginning of a Custom Permalink
- Permalink misbehaving in Custom Post Types
- I’m having trouble getting the permalink sample on my custom post type edit page to work
- Remove custom permalink structure from custom post type without modifying register_post_type() directly
- One Custom post type 404’s others don’t
- How to add a sub directory to WordPress single posts without affecting other post types?
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- Custom Post Type to replace Woocommerce products – page not found error
- Ideas on how to organize a project [closed]
- WordPress Custom URLs
- Which is the neatest way to have homepage articles and a blog?
- Redirect to URL if x number of days passed
- Custom rewrite rules for /pastissues/%category%-%postname%.html
- Subpages Permalinks Issues
- Multiple permalinks for a single post with multiple taxonomies
- Stop displaying Permalink
- Duplicate slug/permalink issue while adding same post name
- Permalink with hierarchy of Custom Post Types
- Rewrite URL for CPT to domain/post-name/post-id
- Custom Endpoint For Specific Custom Post Type
- How do you create pillar content pages?
- Custom permalink structure for custom post types including multiple taxonomy
- Custom post type single page returning 404 error when sharing archive url with custom taxonomy
- Customise Permalink Structure For Custom Post Types
- How to make “single post” permalink maintain it’s sub-page structure
- Two and more diffrent custom page type in one permalink
- Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks
- Page as parent for CPT and other pages
- Two CPT: one is using part of the custom rewrite slug from the other
- Custom permalink with custom taxonomies for custom post type
- Change the url of a custom post type to include taxonomy
- how to use two permalinks for one custom post type based on categories
- Can I override the permalink/slug on creation
- How to have permalink structure based on taxonomy terms
- Multiple custom post type and permalink issue
- How to switch from custom post type URL to category URL?
- Remove sequential number from permalinks
- Permalinks when using Custom Post Type with static page for archive
- How to change permalinks to taxonomy and post type’s posts
- Customizing the custom post type permalink
- Have two (permalinks) urls for a same custom post type
- change precedence of permalink for post_types?
- Redirect permalinks after creating custom post types
- Parent cpt/child custom post type URL permalink relationship
- How to make nested custom post type slugs work
- Custom Post Type Permalinks Problem
- Problems with custom post type and hierarchical permalinks
- Custom Post Types and 404 Pages
- Permalink for Custom Post Types
- wp_redirect to file:// location results in blank page/cannot be displayed page
- Posts picking up old Permalinks, how to reset?
- Remove slug from Custom Category Permalink + dual-category permalinks
- WordPress Set A Static Page/Template For All Sub-Pages
- Get permalink in custom post type loop doesn’t work
- How to add custom permalink struct with DYNAMIC author to a Custom Post Type
- Custom post type Premalinks main page and details page
- Permalinks for Custom Post Types and Taxonomies
- How to change permalink structure off default posts and also CPT’s posts