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
- Using /%postname% for a custom post type
- Why would WordPress use ‘attachment’ in a custom post type’s query string?
- Custom post type URL with post ID that allows archiving and paging
- Changing the URL Structure of a Paginated Custom Post
- Custom post type taxonomies URL rewrite
- Enforcing canonical URLs with multiple custom post types
- 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 permalinks
- Issues when rewrite rules collide?
- Custom post type permalink changing itself every other change
- 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
- How to create custom URLs for Custom Post Type sub sections?
- Custom Permalinks for Custom Post Types and Taxonomies
- Rewrite custom post type url’s adding meta box values
- Custom Post Type Rewrite Rule for Author & Paging?
- Removing parent slug from URL on custom post type
- Multiple parameters in a custom post type url rewrite
- URL rewrite and navigation structure for wordpress custom post type
- How to properly prefix blog post URL’s
- Custom post type category, taxonomy and URL rewrite problem
- Rewrite on custom post type permalink not working?
- Custom post-type in root directory, blog posts in subdirectory
- Custom Post Type/ Taxonomy URL rewrite
- Custom query variable – get wordpress to redirect to nice permalink url
- how to get archive urls with same origin for custom types and terms?
- Permalinks for Taxonomy and Custom Post Type
- Multisite with a single, shared custom post type, while retaining site URL
- 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
- Rewrite URL for only archive page (custom post type)
- Remove base slug in permalinks of hierarchical custom post type
- Change custom post type slugs, with category/taxonomy before post type name
- Rewrite rules for custom posts types
- wp_list_categories() – current-cat class also inside posts?
- Custom Post Types, URL rewrite on multiple CPTs
- 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?
- Index page with the same id as the slug
- Custom post type as home page with custom url
- How to rewrite url for any specific taxonomy?
- Custom post URL 404 error
- URL rewrite add author as base
- 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
- URL rewriting for CTP assigned entity
- CPT’s with landing page instead of archive – Url Rewrite?
- 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)
- Best way to specify “article type” in URL
- How to have permalink like domain.com/term/postname?
- post_type_link Filter – Too Few Arguments
- WordPress rewrite url
- url rewriting for custom post types
- Post type Permalink
- How to rewrite the post slug of a custom post type post
- Custom post type URL
- Archive page for custom post type and custom taxonomy
- Why does my URL keep returning 404 error code?
- Custom Post Type nest under a normal WordPress Page
- Combine 2 different custom post slugs into a single permalink?
- Use a different URL path / permalink for CPT
- Setting Parent Page to Post
- Add rewrite rule for custom post type single page
- Custom taxonomy terms as children of multiple custom post types
- Custom Post Type & Taxonomies – Rewrite
- Remove custom permalink base from CPT custom category and custom tags
- How to change URL for custom post type archive?
- How to handle this wordpress custom post type rewrite problem?
- Custom Post Type not using correct page template
- Change CPT permalink to use the category
- add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working
- Rewrite of Custom Post Type doesn’t work with dynamic data
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- add_rewrite_tag broke permalinks that doesn’t use that specific tag
- How to use a custom post type as child of a particular post of another CPT?
- Custom URL for Custom Post Type & Custom Taxonomy Term
- Custom taxanomy and custom post type – pagination leads to 404
- Flush rewrite rules when new cpt is registred
- Custom post url in search.php isn’t the correct rewrited url
- I have a custom taxonomy assigned to two post types. How do I create URLs for different term archives for each post type?
- Custom WordPress URL
- Customizing the custom post type permalink
- URL Rewrite Adjustment for Custom Post Type causes template to revert to index.php
- Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://domain.com/custom-post-type/category/cat-name/page/page-number
- 2nd and 3rd Custom Post Type URL’s 404ing
- Custom Post Type – Rewrite slug [duplicate]
- Generate daily archive whenever any post type is added
- Rewrite rules for using the same base slug for multiple content types
- add_rewrite_rule not working in Custom Post Type UI Plugin
- Menu Structure and URL structure, with Pages and Post-Type-Posts