Git Product home page Git Product logo

Comments (6)

gfirem avatar gfirem commented on July 20, 2024 1

Hi, resolve by my own. I use the filter aal_init_roles, see the next example.

add_filter( 'aal_init_roles', array( $this, 'aal_init_roles' ) );

public function aal_init_roles( $roles ) {
    $roles_existing          = $roles['manage_options'];
    $roles['manage_options'] = array_merge( $roles_existing, array( "CustomRole" ) );

    return $roles;
}

I insert using the next function aal_insert_log( $args );

    aal_insert_log( array(
        'action'         => "Updated",
        'object_type'    => 'CustomRole',
        'object_subtype' => "tooltips-attributes",
        'object_name'    => "Updated tooltips attributes. <div id='log_full_description' class='privanz_log_full'> " . $diff . "</div>",
    ) );

I need to insert more data in the description and i change the current type of the mysql column like the next script.

public function set_aryo_activity_log_column() {
    global $wpdb;
    $type = $wpdb->get_var( "SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'wp_aryo_activity_log' AND column_name = 'object_name'" );
    if ( $type == "varchar" ) {
        $wpdb->query( "ALTER TABLE wp_aryo_activity_log CHANGE COLUMN object_name object_name blob" );
    }
}

And finally i am saving a big json inside the description i change the column into the log table using the next code and insert a code to show a popup in the footer.

    add_action( 'aal_table_list_column_description', array( $this, 'log_description' ), 10, 2 );
    add_filter( 'admin_print_footer_scripts', array( $this, 'include_in_footer' ), 50 );

public function log_description( $return, $item ) {
    if (strpos($return, 'log_full_description') !== false) {
            $return = $return . " <a class='log_more_btn' href='#'>" . __( "more", "xxx" ) . "...</a>";
    }

    return $return;
}
public function include_in_footer() {
    global $plugin_page;
    if ( 'activity_log_page' != $plugin_page || ! is_admin() ) {
        return;
    }
        ....
}

I hope this code help to other!
www.gfirem.com

from activity-log.

maor avatar maor commented on July 20, 2024

Most definitely, @netconstructor!

What you can do is use the aal_insert_log() method,
which will allow you to insert whatever event you'd like.

You can also take a look at some examples, found in the hooks directory within the plugin.

Good luck implementing!

from activity-log.

netconstructor avatar netconstructor commented on July 20, 2024

Thank you for your response. I have been attempting to implimented a custom logged activity hook through your plugin but I seem to be unable to get this implimented correctly.

I want to ensure my objective is properly implimented with minimal load on the system while properly hooking/logging all pageviews to any frontend pages (no backend page views) and only for those users who are properly logged in.

In your professional expertise and direct experience could you please clarify if my objective is far more involved than it should be? If possibly and not overly complicated I would greatly appreciate if you might be able to provide the proper code to achieve this properly. Greatly appreciate your help here in advance!

from activity-log.

netconstructor avatar netconstructor commented on July 20, 2024

Bump

from activity-log.

gfirem avatar gfirem commented on July 20, 2024

I have and issue like this, i insert the data with aal_insert_log() but not showing in the list of logs, but is inserting in the data base, i miss something?

from activity-log.

dmbostan avatar dmbostan commented on July 20, 2024

Facing the same issue. as @gfirem. Any idea why the logs are not displayed in WP admin list ?

from activity-log.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.