Home / Admin / CPT_DIR – Users
Duplicate Snippet

Embed Snippet on Your Site

CPT_DIR – Users

Directory of portal users....

ismail daugherty PRO
<10
Code Preview
php
<?php
/**
 * WPCode Snippet: WordPress Users & BuddyBoss Profiles CPT Registration
 * Description: Registers custom post type for user/profile sync with full REST API support
 * Location: Run Everywhere
 * Priority: 0
 * 
 * INSTALL ORDER: #1 - Install this first, before ACF fields and sync code
 */
defined( 'ABSPATH' ) || exit;
add_action( 'init', function() {
    $labels = [
        'name'                     => 'User Profiles',
        'singular_name'            => 'User Profile',
        'menu_name'                => 'Users Sync',
        'all_items'                => 'All User Profiles',
        'add_new'                  => 'Add New',
        'add_new_item'             => 'Add New User Profile',
        'edit_item'                => 'Edit User Profile',
        'new_item'                 => 'New User Profile',
        'view_item'                => 'View User Profile',
        'search_items'             => 'Search User Profiles',
        'not_found'                => 'No user profiles found',
        'not_found_in_trash'       => 'No user profiles found in Trash',
        'item_updated'             => 'User profile updated',
    ];
    
    register_post_type( 'users_bb_sync', [
        'labels'              => $labels,
        'description'         => 'WordPress user data and BuddyBoss extended profiles synchronized to custom post type',
        'public'              => false,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'menu_position'       => 31,
        'menu_icon'           => 'dashicons-admin-users',
        
        // REST API support - CRITICAL for WhaleSync
        'show_in_rest'        => true,
        'rest_base'           => 'users-bb-sync',
        'rest_controller_class' => 'WP_REST_Posts_Controller',
        
        // Security
        'capability_type'     => 'post',
        'map_meta_cap'        => true,
        
        // Features - MUST include 'custom-fields' for meta exposure
        'supports'            => [ 'title', 'custom-fields', 'revisions' ],
        'hierarchical'        => false,
        'has_archive'         => false,
        'rewrite'             => false,
        'query_var'           => true,
        'exclude_from_search' => true,
        'can_export'          => true,
        'delete_with_user'    => false,
    ] );
}, 0 );

Comments

Add a Comment