I think the post needs to be inserted first. This is a sample function that updates the post slug after it’s been inserted.
// Update post slug
$my_post['ID'] = $pid;
$my_post_name="post_name" . "-" . $pid;
$my_post['post_name'] .= $my_post_name;
// Update the post into the database
wp_update_post( $my_post )
It’s combining the post_name with post ID to create the URL. You also may want to look at http://codex.wordpress.org/Function_Reference/register_post_type which goes over the options for setting slugs. I’m not sure if you want to allow your members to be able to set their own permalink or if you want that disabled and to have it generated in the background.
Related Posts:
- Rewriting a custom-post-type permalink with taxonomy term?
- Remove custom post type slug from URL
- Custom post type, no need for single view, plus want permalink rewrites that include hash in URI
- Custom post type yearly/ monthly archive permalinks
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Using /%postname% for a custom post type
- Changing the URL Structure of a Paginated Custom Post
- Adding meta values to permalink
- Custom post type taxonomies URL rewrite
- WordPress custom taxonomy URL rewrite on spelling errors
- How can i avoid the permalink start with ‘blog’ while using the custom post type?
- Custom Posttype Inheritance (and url structure)
- Permalinks so that one custom post type appears to be a child of another, not working
- Create permalink structure for one taxonomy archive per custom post type
- Custom post type’s get_permalink returns wrong url
- Custom post type permalink structure with the category also acting as an archive
- Prepend meta_value to permalink of post
- Defining a default page for custom post type
- Pass parameter to custom post type single while keeping clean url
- Rewrite custom post type url’s adding meta box values
- Multiple parameters in a custom post type url rewrite
- URL rewrite and navigation structure for wordpress custom post type
- Removing CPT slug from URL results in 404 error for archive page
- Many to Many Taxonomies or rewrite rules?
- How to properly prefix blog post URL’s
- remove post-name from title in custom post type
- Getting Post ID from slug during init
- Rewrite custom post & taxonomy to share same URL path
- Adding a date archive to Custom Post Type
- Custom Post Type/ Taxonomy URL rewrite
- how to get archive urls with same origin for custom types and terms?
- Permalinks for Taxonomy and Custom Post Type
- Share parent path between Custom Post Types and Pages?
- multiple url slug for single custom post type
- Pretty URLs for Custom Post Type & Custom Taxonomy with Duplicate Slugs on WPML
- Custom Post Type and Custom Taxonomy Permalinks
- Pagination problem
- Custom Post Type Post have a Child `Page` Post Type Post
- remove permalink “front part” for custom post type
- Query var removed after rewrite
- Change custom post type slugs, with category/taxonomy before post type name
- Add archive slug to default post post type
- wp_list_categories() – current-cat class also inside posts?
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Set a CPT slug as a base name for all the taxonomies
- Custom taxonomy rewrite with query var returns %2F in URL
- Remove slug in URL custom post type
- cpt and page sharing same base permalink
- Custom post Type, child of a Page?
- Hide or disallow default custom post type url?
- URL rewriting for CTP assigned entity
- Custom taxonomy returns 404
- Added Custom Post Type and the View Option Doesn’t Work
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Specific routing for CPT
- Lost of query parameter when using permalink
- Custom permalink with child taxonomy terms
- Custom post type archive with page as parent url
- Pagination custom post type not working with rewrite slug
- Custom Rewrite Rule for Custom Post Type with URL Param
- WordPress custom slug rewrite
- WordPress Custom Post Type – Rewrite Query
- After creating Custom post type by user delete old one
- Set parent for custom post type archive rewrite url
- Dynamic CPT permalink structure based on ACF field value
- URL Rewrite – Page Archive
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- custom post archive URL is wrong
- Rewrite rules for custom post type
- Custom taxonomy and post type rewrite rules
- Custom Post Type and Taxonomy Rewrite Error
- custom posts permalinks url rewriting
- WordPress is ignoring my post rewrite rule
- Url Rewriting a dynamic wordpress page with parameters
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- Duplicate content problems after adding an archive page to the article’s post type
- Display CPT taxonomies as an archive page
- CPTUI rewrite disable when no post in CPTUI has been found
- Redirect Custom Post Type from Child Taxonomies
- Set archive of custom post type like ‘posts’ page in reading settings is set
- Register post type getting error 404
- Custom post type rewrite and wp_pagenavi interfering with each other
- CPT url rewriting : regular posts return 404 error
- redirect old post type url to new structure url
- One custom post type with two different url structure base on taxonomy term
- Why is a custom post type’s URL “/?cposts=name-of-the-post” but default post’s URL is “/?p=ID”?
- How can you preserve URLs when moving posts to a custom post type?
- Custom Post Type Base URL
- Custom Taxonomy in Permalink from post type
- Custom Post Type and single-posttype template
- How to rewrite custom slugs that follow my rules
- Custom post type with custom taxonomies structure url not working archive of CPT
- What is the best way to relate different custom post types?
- Allow child pages with the same base as the CPT slug
- How to work with URLs where sometimes a post or a subcategory is in the same part of the URL structure
- How to make 2 (or more) custom post type post pages sit under the same slug?
- Remove date rewrite rule for custom post type archive page
- Display content based on multiple URL parameters—pretty URL or query string