Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter IM_natascha

    (@im_natascha)

    I found another thing my common sense is struggling with:

    My workflow with roles is to add those roles everytime WP loades, so if i add a capability to this role, it will be assigned to the $wp_roles->roles BUT NOT to the $wp_roles->role_objects. If I now set a WP_User-Object, it will get all capabilities by $wp_role->get_caps($role) and this will look into $wp_roles->role_objects — this was where the currently added capabilities weren’t applied to!

    I ended up with capabilities which contained the identifier of the role, granted and all capabilities, directly asigned to when creating the role, but none of the capabilities added later on!

    Who else has problems, simply add the following line:

    /**
    	 * Add capability to role.
    	 *
    	 * @since 2.0.0
    	 * @access public
    	 *
    	 * @param string $role Role name.
    	 * @param string $cap Capability name.
    	 * @param bool $grant Optional, default is true. Whether role is capable of performing capability.
    	 */
    	function add_cap( $role, $cap, $grant = true ) {
    		$this->roles[$role]['capabilities'][$cap] = $grant;
    		$this->role_objects[$role]->capabilities[$cap] = $grant; // ADD THIS LINE
    		if ( $this->use_db )
    			update_option( $this->role_key, $this->roles );
    	}
    Thread Starter IM_natascha

    (@im_natascha)

    I think it would also be a great idea to make Roles be translated while needed:

    You give them a String, such as ‘My-Member’ and while returning the name, WP translates it for you.
    You would need a text-domain for each role and change the function a bit.

    function get_names() {
    	// old return $this->role_names;
            // new:
            $returning = array()
            foreach($this->role_names as $role => $name) {
                 $returning[$role] = __($name, $this->roles[$role]['textdomain']);
            }
            return $returning;
    }

    Thread Starter IM_natascha

    (@im_natascha)

    AdminMenu.php

    abstract Class AdminMenu {
      __construct($params) {}
      abstract function register_with_wp();
      final function add_Action() { add_action('admin_init', array(&$this, 'register_with_wp')); }
    }

    Benutzung:

    $menu = new AdminMenu($params);
    $menu->add_action();

    Die Funktion ist erst verfügbar, wenn do_action('admin_init') aufgerufen wird.

    Wers benutzen will: abstract Klassen kann man nicht direkt verwenden.

    Forum: Fixing WordPress
    In reply to: load jquery
    Thread Starter IM_natascha

    (@im_natascha)

    Is there anyone who knows a solution?

    Forum: Fixing WordPress
    In reply to: load jquery
    Thread Starter IM_natascha

    (@im_natascha)

    Funny – if it would have been loaded, my test should have worked but didn’t. So I thought, I needed to load jQuery.

    As my function didn’t work, I hardcoded the import of jQuery.
    I tested it right now – without my hardcoded jQuery-Import my Script does not work, so jQuery is most likly not imported. I even searched the html-code, but as expected didn’t find anything about jQuery.
    Maybe the jQuery-Lib is not loaded for the registration page.

    Thread Starter IM_natascha

    (@im_natascha)

    It gave me a headache, but at last i won. ??

    For everyone who has a similar problem, try this:
    -> hook to ‘save_post
    -> write following code into the callback function
    $wpdb->get_var( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = %d WHERE ID = %d", $value, $post_id) );

    The infinite loop was created by calling a WP-post-function. This function caused ‘save_post’-hooks to be repeatedly called who themself called the WP-post-function again. Finally the request timed out.

    The solution is simple, by inserting directly with the global $wpdb class (this will not call ANY hooks!!).
    Whoever is familiar with MySQL will not need any further support on this, everyone else shouldn’t try to destroy their databases and learn MySQL-statements first.

    Thread Starter IM_natascha

    (@im_natascha)

    I found this topic named: Setting post_parent during wp_insert_post but this did not help me.

    wp_update_post( array(‘ID’ => $post_id, ‘post_parent’ => $parent) );

    Seems like i create an infinite loop.

    Anyone who can help?

    If you have access to your database do as follows:

    1. open “Create New Post” or “Edit Post” site in your browser
    2. change the screen-option “colums” to whatever isn’t selected at the moment
    3. delete following usermetas in one step, then refresh your browser (reloading will recreate the fields, therefore you need to delete all listed fields before you refresh your browser):
    3. a) wp_user-settings
    3. b) wp_user-settings-time
    3. c) meta-box-order_{posttypeWhereYouChangedTheLayOutGoesHere}
    [!!!] Pay attention to only delete these fields and only where the user-ID is the ID of your user.

    This worked for me in WP 3.0.1
    I will not take any responsibility for any errors that will occur if you follow these steps – although one who knows how to handle databases and manipulate rows in his database will most likely not face any problems.

    Thread Starter IM_natascha

    (@im_natascha)

    thank you xdesi!
    If they might remove it, it will be better to write the long way – just in case ??

    Thread Starter IM_natascha

    (@im_natascha)

    resolved.

    Seems like WordPress or my PHP installation does not support
    <?=
    and therefore the array resulting from tax_input[<?= $taxonomy ?>] had a wrong associative key.

    Thread Starter IM_natascha

    (@im_natascha)

    Yes, this might work.

    As i do not have any further questions on this topic, i mark it as resolved, thanks to the wpua ??

    Thread Starter IM_natascha

    (@im_natascha)

    So, does anyone know a way how to stop the process of inserting a new post if the inserted term was not correct?

    Thread Starter IM_natascha

    (@im_natascha)

    From what i can see now, your code works fine (if i do not forget to change “gender” to my own taxonomy-name *gg*) after adding the 2 optional parameters.

    at last but not least: is there a trick how i can forbid to insert the post into the database if the term is wrong?
    otherwise i will have a look at your suggested add_meta_boxes-Action tomorrow.

    Thread Starter IM_natascha

    (@im_natascha)

    Thank you! Sounds pretty fine but i challenge an error with your code (beside the ‘)’ which is missing :P)

    Missing argument 2 for NK_Association::check_right_term() […]

    You call two parameters, but it seems like the filter isn’t passing them correctly. I didn’t work a lot with filters yet so i can’t see the error at first sight, might you?

    P.S.: Impressed by answering-speed ??

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