latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Conflict with Achievements Plugin

Home Forums Community Forum Conflict with Achievements Plugin

This topic contains 3 replies, has 2 voices. Last updated by  Bruce 3 years, 5 months ago.

Topic Author Topic
Posted: Thursday Jul 18th, 2013 at 9:51 am #53631
Norm H
Username: mrdirby

Hi,

There is a know issue with s2Member and the Achievements plugin.

http://wordpress.org/support/topic/add-badges-with-s2-member

It seems the problem is with the Achievements plugin. However I’m not sure what to add to the suggestion by the plugin author.

take a look at includes/core/caps.php in the plugin — specifically the

dpa_get_caps_for_role() 

plugin. You’ll want to use that filter to add appropriate capabilities to the new roles.

Here is the code around that area.

function dpa_add_caps() {
	global $wp_roles;

	// Load roles if not set
	if ( ! isset( $wp_roles ) )
		$wp_roles = new WP_Roles();

	// Loop through available roles
	foreach( $wp_roles->roles as $role => $details ) {

		// Load this role
		$this_role = get_role( $role );

		// Loop through available caps for this role and add them
		foreach ( dpa_get_caps_for_role( $role ) as $cap ) {
			$this_role->add_cap( $cap );
		}
	}

	do_action( 'dpa_add_caps' );
}

Any suggestions?

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Tuesday Jul 23rd, 2013 at 4:19 am #53848
Bruce
Username: Bruce
Staff Member

Thank you for reporting this important issue.

And thank you for your patience with us over the weekend.

I’m not familiar with the achivements plugin myself, but it sounds like it’s doing something similar to what bbPress does (adding capabilities to certain Users).

What you’ll need to do is two things. First off, this thread goes over how you add Capabilities to Roles directly:

http://wordpress.stackexchange.com/questions/13413/how-to-add-a-capability-to-a-user-role

You’ll want to get all of the capabilties that are required for your external plugin, and add them like this:

<?php
$role = get_role('subscriber'); // For Subscriber Role

$role->add_cap($cap_name);
$role->add_cap($another_cap);

By the looks of your code snippet, you’ve gotten that far. The issue with your code *probably* has to do with this call:

dpa_get_caps_for_role( $role )

If the name of that function is correct, then this is only looking for the Capabilities for the achievement plugin the Role already has. You need to add the roles that it does not have. Try looking at the plugin’s API or ask the developer if there is a list of required Capabilities for this.


Once you’ve got these Capabilities added to your plugin, you’ll want to lock your Roles and Capabilities to keep s2Member from overriding them in the next update. You can see this article on that:

Knowledge Base » Locking s2Member Roles/Capabilities

Posted: Tuesday Jul 23rd, 2013 at 11:24 am #53886
Norm H
Username: mrdirby

Is the name of the role always ‘s2member_level1’ or ‘s2member_level2’ or is the role name related to what label I gave it in the dashboard?

Posted: Tuesday Jul 23rd, 2013 at 7:47 pm #53904
Bruce
Username: Bruce
Staff Member

Is the name of the role always ‘s2member_level1′ or ‘s2member_level2′ or is the role name related to what label I gave it in the dashboard?

The slug for the Role (which is what you’re using here) never changes, even when you change the label for the Role.

Viewing 3 replies - 1 through 3 (of 3 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.