Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




tags custom taxonomy issue

UserPost

5:51 am
October 5, 2011


mandreatta

Member

posts 4

1

Hi all,

I've registered a "non hierarchical" taxonomy to have "tags" on a custom post type I've just created, basically:

….

register_post_type('mypost',$args);

….

register_taxonomy('mypost_tags','mypost',$args);

….

Then I set up RS to allow [WP subscribers] contributing "mypost" post type and to add "mypost_tags" tag to them (Roles -> General -> assign to [WP subscribers] "mypost_tags Assigner" role).

Everything works for admin users, but when a  [WP subscribers] user tries to save a "mypost" post, gets the following error:

Warning: array_map() [function.array-map]: Argument #2 should be an array in /home/htdocs/wp-content/plugins/role-scoper/cap-interceptor_rs.php on line 491

Warning: array_unique() expects parameter 1 to be array, null given in /home/htdocs/wp-content/plugins/role-scoper/cap-interceptor_rs.php on line 491

Warning: Cannot modify header information - headers already sent by (output started at /home/htdocs/wp-content/plugins/role-scoper/cap-interceptor_rs.php:491) in /home/htdocs/wp-includes/pluggable.php on line 934

Please, any idea?

Thanks,

Marco.

7:28 am
October 5, 2011


Kevin

Admin

posts 2503

2

It sounds like there may be something wrong with your $args. Try it without passing in any capabilities or capability_type.

8:30 am
October 5, 2011


mandreatta

Member

posts 4

3

Hello Kevin,

Thanks for your feedback. Unfortunately It's not that simple, there is no capabilities property into $args:

    $labels = array(
        'name' => 'mypost',
      );
    $args = array(
        'labels' => $labels,
        'hierarchical' => false,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'mypost' ),
    );
    register_taxonomy(
        'mypost_tags',
        'mypost',
        $args
    );

FYI: the version of RS is the last: 1.3.46

Any idea?

Thanks,

Marco.

8:46 am
October 5, 2011


Kevin

Admin

posts 2503

4

The PHP warnings pertain to the custom post type definition, not the taxonomy.

9:44 am
October 5, 2011


mandreatta

Member

posts 4

5

Before writing in this forum I've debugged the code and the issue appears to be caused by tags not being contained into an array. i.e. the line 491 of cap-interceptor_rs.php is:

$set_terms = array_unique( array_map('intval', $set_terms) );

$set_terms not being an array, but a string with tags comma separated like e.g. "test1,test2″

That's why array_map fails…

Moreover there is no capability propery set into "mypost" custom post type….

Marco.

10:06 am
October 5, 2011


Kevin

Admin

posts 2503

6

Oh, sorry, I was looking at line 491 in RS 1.3.47-dev, not 1.3.46.

For now, can you try modifying cap-interceptor_rs.php as follows:

change:

$selected_terms = cr_get_posted_object_terms( $taxonomy );

to:

$selected_terms = cr_get_posted_object_terms( $taxonomy );

if ( is_scalar($selected_terms) ) {
	$term_names = explode( ',', $selected_terms );
	$selected_terms = array();

	foreach( $term_names as $name ) {
		if ( $_term = get_term_by( 'slug', $name, $taxonomy ) ) {
			$selected_terms[]= $_term->term_id; 
		}
	}
}

10:24 am
October 5, 2011


Kevin

Admin

posts 2503

7

Actually, I'm going to modify the source as shown below. Non-hierarchical tags don't need to be pre-inserted for query filtering purposes.

if ( is_array($selected_terms) ) {
    if ( $set_terms = $GLOBALS['scoper_admin_filters']->flt_pre_object_terms($selected_terms, $taxonomy) ) {

       // ... other set_terms code...
    }
}

10:29 am
October 5, 2011


mandreatta

Member

posts 4

8

Yes, It works!

So, I guess It's a bug which will be fixed in next RS release.

This is a great wp plugin, I really appreciate your work.

Thanks,

Marco.


About the Agapetry forum

Currently Online:

12 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1249

Posts: 5659

Members:

There are 1261 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin