Support » Plugin: Subscribe2 - Form, Email Subscribers & Newsletters » Custom Taxonomies not showing in settings.

  • Resolved mileskimberley

    (@mileskimberley)


    We have created a plugin for Subscribe2, that should add support for a custom post type called ‘job’ and a custom taxonomy called ‘member’.

    The plugin is sending out emails when a new job is posted, but we need to be able to only subscribe to jobs added to our own member taxonomy.

    Here is the code we are using:

    <?php
    /*
    Plugin Name: Job Notifier
    Version: 1
    */
    
    function my_post_types($types) {
    $types[] = 'job';
    return $types;
    }
    
    add_filter('s2_post_types', 'my_post_types');
    
    function my_taxonomy_types($taxonomies) {
    $taxonomies[] = 'member';
    return $taxonomies;
    }
    add_filter('s2_taxonomies', 'my_taxonomy_types')
    
    ?>

    However the settings page is only showing the default categories, not our custom post type…

    https://wordpress.org/plugins/subscribe2/

Viewing 15 replies - 1 through 15 (of 21 total)
  • Thread Starter mileskimberley

    (@mileskimberley)

    I’ve noticed that the custom taxonomies are added to the end of the normal categories list, however I am receiving emails for all taxonomies, not just the one I’ve ticked.

    Also is there a way to hide the default categories and just display the custom taxonomies?

    mattyrob

    (@mattyrob)

    @mileskimberley,

    the ‘s2_taxonomies’ filter takes the current set of taxonomies (i.e. categories) and allows that to be added to or over ridden. You are currently adding your ‘member’ taxonomy to the array with $taxonomies[] instead you need to change that line to:
    $taxonomies = array('member');

    Thread Starter mileskimberley

    (@mileskimberley)

    Thanks,

    That cleans up the settings screen, but I am still receiving post notifications for taxonomies that I have not ticked…

    mattyrob

    (@mattyrob)

    @mileskimberley,

    I don’t really understand what you mean, you only have 2 taxonomies, categories and members – right?

    Thread Starter mileskimberley

    (@mileskimberley)

    We have a member taxonomy which is used to assign a job to a Team Member, I only wish to receive an email when a new job is assigned to me.

    I therefore tick the Miles box in the Subscribe2 settings, however I receive an email when any new job is added, not just the ones given the Miles member taxonomy…

    mattyrob

    (@mattyrob)

    @mileskimberley,

    Is your account being used as the sender account and do you have the number of recipients per email set to something other than 1 in the subscribe2->Settings page under the Email Settings tab?

    Thread Starter mileskimberley

    (@mileskimberley)

    ‘Restrict the number of recipients per email to’ is set to 1 and the ‘Send Email From’ setting is set to ‘Post Author’

    mattyrob

    (@mattyrob)

    @mileskimberley,

    That all seems correct. I’m not sure I can suggest anything further without seeing you site.

    Thread Starter mileskimberley

    (@mileskimberley)

    We used Custom Post Type UI to create the custom post type and taxonomy, would that make a difference?

    If there’s nothing you can suggest, is there at least a way to get the {CATS} shortcode in the template to work with the custom taxomony, so I can put the member name in the email subject?

    mattyrob

    (@mattyrob)

    @mileskimberley,

    The Custom Post Type UI should make any difference unless the post type name is not correct.

    I presume from what you are saying, the {CATS} keyword doesn’t work. That would indicated that the post type or taxonomy are not quite right though. you could try calling the core get_taxonomies() and get_post_types() functions to see what taxonomies and post types are registered and what names are being used.

    Thread Starter mileskimberley

    (@mileskimberley)

    get_taxonomies shows the below list:
    status
    member
    type

    get_post_types shows the below list:
    job

    Presumably the taxonomies would not be displayed on the settings page if there was an error there and I wouldn’t be receiving an email when new jobs are added at all if that was the issue?

    Thread Starter mileskimberley

    (@mileskimberley)

    The code generated for the taxonomy by CPT UI is as below:

    add_action('init', 'cptui_register_my_taxes_member');
    function cptui_register_my_taxes_member() {
    register_taxonomy( 'member',array (
      0 => 'job',
    ),
    array( 'hierarchical' => true,
    	'label' => 'Team Members',
    	'show_ui' => true,
    	'query_var' => true,
    	'show_admin_column' => true,
    	'labels' => array (
      'search_items' => 'Team Member',
      'popular_items' => '',
      'all_items' => '',
      'parent_item' => '',
      'parent_item_colon' => '',
      'edit_item' => '',
      'update_item' => '',
      'add_new_item' => '',
      'new_item_name' => '',
      'separate_items_with_commas' => '',
      'add_or_remove_items' => '',
      'choose_from_most_used' => '',
    )
    ) );
    }

    If that helps…

    Thread Starter mileskimberley

    (@mileskimberley)

    And for the jobs post type:

    add_action('init', 'cptui_register_my_cpt_job');
    function cptui_register_my_cpt_job() {
    register_post_type('job', array(
    'label' => 'Jobs',
    'description' => '',
    'public' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'capability_type' => 'post',
    'map_meta_cap' => true,
    'hierarchical' => false,
    'rewrite' => array('slug' => 'jobs', 'with_front' => 1),
    'query_var' => true,
    'has_archive' => true,
    'menu_position' => '5',
    'supports' => array('title','editor','revisions','thumbnail','author'),
    'taxonomies' => array('category','status','member','type'),
    'labels' => array (
      'name' => 'Jobs',
      'singular_name' => 'Job',
      'menu_name' => 'Jobs',
      'add_new' => 'Add Job',
      'add_new_item' => 'Add New Job',
      'edit' => 'Edit',
      'edit_item' => 'Edit Job',
      'new_item' => 'New Job',
      'view' => 'View Job',
      'view_item' => 'View Job',
      'search_items' => 'Search Jobs',
      'not_found' => 'No Jobs Found',
      'not_found_in_trash' => 'No Jobs Found in Trash',
      'parent' => 'Parent Job',
    )
    ) ); }
    mattyrob

    (@mattyrob)

    @mileskimberley,

    That all looks right – what are the ‘status’ and ‘type’ taxonomies? Have you created those too?

    Thread Starter mileskimberley

    (@mileskimberley)

    Yes, they were also created with CPT UI, status showing the status of the job – Complete, In Progress etc and Type showing the type of job – Website, Brochure etc…

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Custom Taxonomies not showing in settings.’ is closed to new replies.