• based on https://codex.www.ads-software.com/Plugin_API/Action_Reference/wp_login it should expect 2 parameters

    $user_login ( username ) and $user ( WP_User object )

    The current hook definition in hookpress is however only defining the first variable
    'wp_login'=>array('user_login'),

    After changing it to the proper one :
    'wp_login'=>array('user_login','USER_OBJ'),
    the plugin runs into a few issues however, due to missing breaks in the switch statement inside the foreach loop in hookpress_generic_action :

    case 'USER_OBJ':
                                    $newobj = (array) $arg;
                            case 'OLD_USER_OBJ':
                                    $newobj = array_map(create_function('$x','return "old_$x";'), (array) $arg);
                            default:
                                    $newobj[$arg_names[$i]] = $arg;

    After adding the break points, only one value was returned, as it seems the WP_User object includes all details inside $user->data, so the final adjustment was so far :

    case 'USER_OBJ':
                                    $newobj = (array) $arg->data;
                                    break;
                            case 'OLD_USER_OBJ':
                                    $newobj = array_map(create_function('$x','return "old_$x";'), (array) $arg);
                                    break;
                            default:
                                    $newobj[$arg_names[$i]] = $arg;

    Is this the way to go, or were the breaks missing on purpose? Possibly this only occurs if the WP_User object is merged with a non-object.

    https://www.ads-software.com/plugins/hookpress/

  • The topic ‘the wp_login action hook’ is closed to new replies.