Skip Navigation

[Resolved] Problem with Toolset Access and cred-delete-post shortcode

This support ticket is created 2 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by umbertoZ 2 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#2385495

Hi, I'm using Access and I've inseted the [cred-delete-post action='delete' onsuccess='self']Delete[/cred-delete-post] shortcode in a View.

If Access is active the Delete link is not displayed.

If I deactivate Access it is displayed.

It seems it works fine for Administrator but not for other custom roles.

Can you check it?

cheers

#2385527

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm having problems getting it to work, too.

I'm going to set up a clean test site to work specifically on this.

I'll get back to you.

#2385567

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

This is a little odd.

I set up a clean site (two, actually).

I found that if you modify the cred-delete-post shortcode so that the action is "trash" rather than "delete" then it appears to work as expected. (If you can verify the same then you should be able to use that setting in the meantime while I investigate further.)

What's odd is that, having tried initially with the delete action (which failed), then switched to the trash action (which worked), I then reverted back to the delete action, and that then started working. So on my test sites I cannot readily reproduce the problem any more, and will need to create another new one to test the initial problem.

I'll bring a clear head to it tomorrow and will report back, but can you verify that it works with trash?

#2386211
screen.jpg
screen2.jpg

Hi Nigel, I made this test:

- I created a new page where I added both Delete and Trash links (see screen2.jpg)

- I set Pages managed by Access (see screen.jpg)

- Then I open the page with an Administrator, a Subscriber and a Residente user

Only the Administrator can see the links (I also tested them and they works as expected), the links are not displayed for the other two roles.

cheers

#2386551

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm still getting into the nitty gritty of where exactly the problem arises, but while investigating I have identified how to apply a workaround that you can use in the meantime.

Try adding the following code snippet (you'll need to edit the array of roles you want to apply this to, which in your case I think will be subscriber and residente):

function ts_mod_caps( $allcaps, $caps, $args, $user ){

    $add_caps = array( 
        'delete_own_posts_with_cred' => true, 
        'delete_other_posts_with_cred' => true 
    );

    $roles = array( 'subscriber', 'contributor' );

    if ( in_array( $user->roles[0], $roles ) ) {
        
        $allcaps = array_merge( $allcaps, $add_caps );
    }

    return $allcaps;
}
add_filter( 'user_has_cap', 'ts_mod_caps', 11, 4 );

Note, it doesn't appear necessary for higher roles, e.g. author and editor.

#2386615

My issue is resolved now.

The workaround worked fine for me.

Thank you!