WordPress.org

Forums

Gravity Forms + Custom Post Types
Custom Taxonomy not being assigned per capabilities (4 posts)

  1. John Chandler
    Member
    Posted 3 years ago #

    I have a special user role (S2member level 2 to be specific) that is posting to a custom post type using a Gravity Form and this plugin. The custom post type capability is set to post. Everything is working properly, except a custom Taxonomy called Specialties is not being properly assigned to the post. However, if I login as an Admin, the taxonomy is properly assigned.

    The register_taxonomy includes this setting:

    'capabilities' => array (
                    'assign_terms' => 'publish_posts'
                    ),

    and publish_posts is assigned to this special user role.

    So, either I'm not using the proper capability, or I've found a bug in the plugin. Any suggestions?

    http://wordpress.org/extend/plugins/gravity-forms-custom-post-types/

    [ Don't bump, that's not permitted here. ]

  2. bradvin
    Member
    Plugin Author

    Posted 3 years ago #

    John,

    The plugin does not look at any user roles or capabilities of the taxonomy. All it does is list them and then saves them to the post using function calls:

    wp_set_object_terms

    or

    wp_set_post_terms

    depending on the type of field used.

    So I do not see how it could be a bug within the plugin?

  3. John Chandler
    Member
    Posted 3 years ago #

    Brad,

    Thanks. So would you speculate the capabilities aren't the issue at all, since the plugin doesn't use them?

    I've test the form logged in as every user level, and the admin is the only one that properly assigns the taxonomies to the CPT.

  4. John Chandler
    Member
    Posted 3 years ago #

    Brad,

    I had a conflict in my page template, because loading the form in a regular template worked fine.

    The template checked to see if the logged in user had already created a post or not, and then didn't give them access to the form if they had. Not sure what the conflict was, but this was the code I was using for future reference:

    <?php $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = $current_user->ID AND post_type IN ('directory') AND post_status = 'publish'" );
    if ($count != '0')  { ?>
    	<?php $loop = new WP_Query( array( 'post_type' => 'directory' , 'posts_per_page' => 1 , 'author' => $current_user->ID ) );
    		while ( $loop->have_posts() ) : $loop->the_post();
    		$link=get_permalink(); ?>
    		<h1 class="entry-title">Manage Your Profile</h1>
    		<div class="entry-content">
    			<p>There is already a Directory Listing connected to this account: <a>"><?php the_title(); ?></a>. Please visit that listing and edit it if you need to update your profile.</p><p>If you would like to cancel your membership, use the link below. Your listing will stay active through the remainder of your annual membership.</p>
    		</div><!-- .entry-content -->
    	<?php endwhile; ?>
    <?php } else { ?>
    	<h1 class="entry-title">Create a Listing</h1>
    	<div class="entry-content">
    		<?php echo do_shortcode('[gravityform id="2" name="Directory Creator" title="false" description="false"]'); ?>
    	</div><!-- .entry-content -->
    
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Gravity Forms + Custom Post Types
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic